Description of problem: upgrading the vixie-cron package (eg. from yum) causes all the @reboot jobs to be run again. Version-Release number of selected component (if applicable): 4.1-55.FC5, but this has happened with previous versions as well. Additional info: for what it's worth, cron-3.0pl1-92 in Debian doesn't have this problem: debian$ strings /usr/sbin/cron | grep Skipping Skipping @reboot jobs -- not system startup
The documentation for '@reboot' in man crontab(5) states: '@reboot : Run once, at startup.' This suggests to me that @reboot jobs should be run at crond startup, which may or may not coincide with system startup, which is how it is implemented in the code. I will treat this as an enhancement request; I think there should be an @boot alias for running jobs only when this is the first instance of crond run after system boot, and the current meaning of '@reboot' should be maintained for compatibility - this is how the upstream vixie-cron has always behaved.
I understand your reasoning, but I'm having trouble thinking of any examples of jobs that I would want to run each time cron is restarted, while I can think of plenty of jobs that I would only want to run once when the system is booted. Furthermore, "reboot" is a pretty well-understood term meaning when the whole system is rebooted, not when one process restarts. So I would request that you reconsider. I hadn't realised this was not a feature of upstream cron. For the record, here is the relevant part of the patch to debian's cron package: --- cron-3.0pl1.orig/cron.c +++ cron-3.0pl1/cron.c @@ -139,7 +268,31 @@ { register user *u; register entry *e; + int rbfd; +#ifdef DEBIAN +#define REBOOT_FILE "/var/run/crond.reboot" + /* Run on actual reboot, rather than cron restart */ + if (access(REBOOT_FILE, F_OK) == 0) { + /* File exists, return */ + log_it("CRON", getpid(),"INFO", + "Skipping @reboot jobs -- not system startup"); + return; + } + /* Create the file */ + if ((rbfd = creat(REBOOT_FILE, S_IRUSR&S_IWUSR)) < 0) { + /* Bad news, bail out */ + log_it("CRON",getpid(),"DEATH","Can't create reboot check file"); + exit(0); + } else { + close(rbfd); + log_it("CRON", getpid(),"INFO", "Running @reboot jobs"); + } + + Debug(DMISC, ("[%d], Debian running reboot jobs\n",getpid())); + +#endif + Debug(DMISC, ("[%d], vixie running reboot jobs\n", getpid())); for (u = db->head; u != NULL; u = u->next) { for (e = u->crontab; e != NULL; e = e->next) { if (e->flags & WHEN_REBOOT) {
Could be future feature - moving to devel.
I look at cron source in debian and their jobs are always running only after reboot of computer. I don't think that's could be feature.
Sigh. That (running @reboot jobs only at reboots) was exactly the point of this feature request! Running jobs on reboot is useful. Running jobs whenever cron gets started doesn't seem to have much purpose I can think of. If your job starts some background process, you most likely only want it to run once at boot.
I agree with you that don't run jobs on reboot make better sense than run them, but I can't change the behaviour for the compatibility. I know that you want new option, but I don't have any idea how could be possible to use pid file in both ways for different options.
Why not a new command line option (or env, etc) that lets you choose the behaviour of @reboot if having a new @boot option isn't easy/possible?