Unreliable shutdown/reboot service on CentOS 8

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

 



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}

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

  Powered by Linux