I am trying to right a systemd service script to perform a task on reboot. Below is the script and it works when I run 'systemctl start script.service but not when I reboot the system.
[Unit]
Description=put cloudify in maintenance mode on shutdown
DefaultDependencies=no
Before=reboot.target
[Service]
Type=oneshot
ExecStart=/bin/cfy maintenance-mode activate
TimeoutStartSec=0
[Install]
WantedBy=reboot.target
I have performed: systemctl daemon-reload and systemctl enable script.service
What that command will do is put an application into maintenance mode.
all services on the vm that are needed for this are also enabled.
I am not sure what I am doing wrong and any help would be appreciated.
To run the service just before your system reboots. You need to add this dependency to your service file.
[Unit]
Description=put cloudify in maintenance mode on shutdown
DefaultDependencies=no
After=final.target
[Service]
Type=oneshot
ExecStart=/bin/cfy maintenance-mode activate
TimeoutStartSec=0
[Install]
WantedBy=final.target