
systemd를 사용하여 스크립트를 실행하려고 합니다. 아래는 제가 사용하고 있는 서비스 정의이지만 재부팅할 때까지 스크립트가 실행되지 않습니다.
[Unit]
Description=Before Shutting Down
Before=reboot.target
RequiresMountsFor=/home
[Service]
Type=oneshot
User=oracle
ExecStart=/home/oracle/scripts/stop_db.sh
RemainAfterExit=yes
[Install]
WantedBy=reboot.target
행운이 있나요? 여러 제안 솔루션을 시도했지만 운이 없었습니다.
서비스 상태:
● dbstop.service - Before Shutting Down
Loaded: loaded (/etc/systemd/system/dbstop.service; enabled; vendor preset: disabled)
Active: inactive (dead)
답변1
데이터베이스를 서비스로 시작 및 중지하고 systemd가 나머지 작업을 수행하도록 하는 것은 어떨까요?
[Unit]
Description=myDB
After=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/oracle/scripts/start_db.sh
ExecStop=/home/oracle/scripts/stop_db.sh
[Install]
WantedBy=multi-user.targetYM