How can I prevent cronjobs from automatically starting after my server has rebooted?
Every time I reboot my server the cronjobs start up again, which I'd like to prevent.
These servers are running Ubuntu 12.04 x32
If memory serves, Ubuntu uses
anacron, which by design runs cron jobs that were missed due to downtime, presumably to make cron jobs more reliable on laptops and other systems that are expected to be turned off more often than servers typically are.
If you don't wish this behavior, switch to another
cron daemon that is not designed to run missed scheduled tasks.
I'm using a very hacky method:
Comment out all cronjob lines:
echo "$(crontab -l)" | sed -e "s/^/#/g" | crontab
Uncomment out all cronjob lines:
echo "$(crontab -l)" | sed -e "s/#//g" | crontab
This way, if I reboot, it's commented out for when the cronjobs start up again.
I hope this answer from Ask Ubuntu is still valid.
On CentOS cron has been removed in favour of anacron - but it works a little bit different there. On Ubuntu:
It burns down to - imho - uninstall anacron. This will remove the anacron binary putting cron into "normal" mode without anacron kicking in.