Re: Help with running a script at shutdown and make it run first before other services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



07.12.2024 01:16, David Elie-Dit-Cosaque wrote:
Hi All,

I am trying to create a systemd service that would execute a script at
shutdown before any other services start receiving shutdown notifications.

You could try

mkdir -p /etc/systemd/system/-.service.d
cat > /etc/systemd/system/-.service.d/after-my-service.conf << EOF
[Unit[
After=my.service
EOF

I came up with this:

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/true
ExecStop=/usr/local/bin/myscript.sh
[Install]
WantedBy=multi-user.target

The script does run after shutdown is initiated but since it relies on
other services which are also shutting down, it fails. Is there a way to
order the shutdown so that  myscript.sh is completed first before
continuing with the shutdown?

Thanks!
David.





[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux