Vixie cron and its descendants have a feature where an entry with the special time specification @reboot in place of the first five date and time fields indicates a one-shot action to be run when the machine is first booted.
But how do you test such entries without actually having to reboot the machine? My thinking was that somewhere crond must note the information that it already has been run once at boot.
Indeed a quick search of the filesystem found the zero length file /var/run/cron.reboot used as a flag that @reboot jobs have already been done.
So, to rerun @reboot jobs:
rm -f /var/run/cron.reboot
followed by:
systemctl restart crond
for systemd systems or
/etc/init.d/crond restart
for SysVinit systems.
But how do you test such entries without actually having to reboot the machine? My thinking was that somewhere crond must note the information that it already has been run once at boot.
Indeed a quick search of the filesystem found the zero length file /var/run/cron.reboot used as a flag that @reboot jobs have already been done.
So, to rerun @reboot jobs:
rm -f /var/run/cron.reboot
followed by:
systemctl restart crond
for systemd systems or
/etc/init.d/crond restart
for SysVinit systems.
No comments:
Post a Comment