<div dir="ltr"><div>Hi,</div><div>This service sometimes works and sometimesĀ it doesn't.</div><div>Does the service die if one of the commands throws an error?</div><div>Or does the system shutdown before the script is done?</div><div>I don't know what's going on and I have tried so many things.</div><div><br></div><div>[Unit]<br>Description = move the files on reboot or shutdown<br>RequiresMountsFor = / /location<br>Before = multi-user.target<br><br>[Service]<br>Type = oneshot<br>RemainAfterExit = true<br>ExecStart = /bin/true<br>ExecStop = /bin/bash /scripts/MoveFilesAndStuff.sh<br>StandardOutput = file:/location/movestufflog.log<br>StandardError = file:/location/movestufflog.log<br><br>[Install]<br>WantedBy = multi-user.target halt.target shutdown.target reboot.target<br><br><br>MoveFilesAndStuff.sh:<br>#!/bin/bash<br>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br>export DISPLAY=:0.0<br>#exec >/ location/scripttestlog.txt 2>&1<br><br><br>\cp -rpf /var /location<br>\cp -rpf /etc /location<br>\cp -rpf /run /location<br>\cp -rpf /root /location<br><br>mv /location/defaultnetcron.xml /location/defaultnet.xml<br>mv /location/vdsmnetcron.xml /location/vdsmnet.xml<br><br>{shutdown a vm command}</div></div>