Geoffrey Leach <geoff(a)hughes.net> writes:
I have this line in /etc/crontab:
30 23 * * * geoff /usr/local/bin/fp.pl
which executes the program every day at 2330. The script terminates by
executing system 'sudo systemctl start poweroff.target';
Generally this works as expected.
However, when I realize that the shutdown happened too soon, and I
restart the system, it re-executes the script.
Any suggestions as to where I've gone wrong?
You didn't wait a minute for before restarting the computer? ;-)
Look at the top of /etc/cron.hourly/0anacron and add logic just like
this to your script. Cron is stateless across reboots (as far as I
know) and has no way to tell if it already ran. You have to record that
fact yourself.
-wolfgang
--
g+:
https://plus.google.com/114566345864337108516/about