[systemd-devel] Unreliable shutdown/reboot service on CentOS 8

Harryo harryo.dk at gmail.com
Fri Aug 13 09:42:16 UTC 2021


Hi,
This service sometimes works and sometimes it doesn't.
Does the service die if one of the commands throws an error?
Or does the system shutdown before the script is done?
I don't know what's going on and I have tried so many things.

[Unit]
Description = move the files on reboot or shutdown
RequiresMountsFor = / /location
Before = multi-user.target

[Service]
Type = oneshot
RemainAfterExit = true
ExecStart = /bin/true
ExecStop = /bin/bash /scripts/MoveFilesAndStuff.sh
StandardOutput = file:/location/movestufflog.log
StandardError = file:/location/movestufflog.log

[Install]
WantedBy = multi-user.target halt.target shutdown.target reboot.target


MoveFilesAndStuff.sh:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
#exec >/ location/scripttestlog.txt 2>&1


\cp -rpf /var /location
\cp -rpf /etc /location
\cp -rpf /run /location
\cp -rpf /root /location

mv /location/defaultnetcron.xml /location/defaultnet.xml
mv /location/vdsmnetcron.xml /location/vdsmnet.xml

{shutdown a vm command}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210813/43f0f33a/attachment.htm>


More information about the systemd-devel mailing list