Search code examples
linuxservicecroncron-task

Alternative for @reboot cron job, start job when cron daemon starts


I have a script which is specified to start on boot-up with the @reboot annotation.

I tried to restart the script by stopping the cron daemon and starting it by entering service crond stop and service crond start, respectively.

However, I noticed that the script doesn't restart at the restarting of the cron daemon, but only when the entire system is rebooted.

My question is, since the cron daemon starts when the system is booted, is there a way start jobs not on reboot but specifically when the cron daemon starts so that service crond stop and service crond start work as expected?


Solution

  • Unfortunately, there is no way to do so, Cron daemon just ignores @reboot directive (CRON) INFO (Skipping @reboot jobs -- not system startup)

    However, if you're trying to start some script at boot time and have ability to restart it without rebooting the machine, you might want to consider creating either init script or, if you're using systemd, systemd service description.(same with upstart and other init replacements)