0

I have a systemd service where I have an issue with stopping the service at the time of reboot.

The script /home/user1/bin/myscript-shutdown relies on filesystem to be up. But it looks like the file system is shutdown (disks unmounted) before completion of /home/user1/bin/myscript-shutdown.

How can I correct the following so the ExecStop script completes first before shutting down any system related services like Storage, Network etc. Likewise, when the system is restarted I want all the system services (storage, Network) started before my service comes up.

I am guessing the trick is in After/Before/Wants but I don't know the correct values.

This is what I currently have:

[Unit]
Description=My Service
After=syslog.target network.target
Wants=network.target
Before=shutdown.target reboot.target halt.target kexec.target

[Service] RemainAfterExit=yes User=user1 Group=group1 LimitNOFILE=65536 LimitMEMLOCK=infinity ExecStart=/home/user1/bin/myscript-startup ExecStop=/home/user1/bin/myscript-shutdown TimeoutStopSec=15min

[Install] WantedBy=multi-user.target

Murthy
  • 1
  • 1
  • The above thread talks about execstart only. There is some discussion about execstop but it is mentioned as separate service. In my case, I have execstart and execstop in the same service. My execstop script relies on filesystem storage and network. So, I want this stop to run before any system targets are shutdown before system goes down. I want execstart script to be executed after all system targets are up. The way it is execstop is getting executed but the filesystem is shutdown before the script is completed. That is the problem. – Murthy Jan 12 '24 at 15:41

0 Answers0