Bug 199220 - cron upgrade reruns @reboot jobs
Summary: cron upgrade reruns @reboot jobs
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: vixie-cron
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-18 03:29 UTC by Andrew Baumann
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-08-20 07:32:46 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Andrew Baumann 2006-07-18 03:29:55 UTC
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

Comment 1 Jason Vas Dias 2006-07-18 15:28:25 UTC
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.
 


Comment 2 Andrew Baumann 2006-07-18 23:45:06 UTC
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) {


Comment 3 Marcela Mašláňová 2007-07-31 10:59:33 UTC
Could be future feature - moving to devel.

Comment 4 Marcela Mašláňová 2007-08-20 07:32:46 UTC
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.

Comment 5 Andrew Baumann 2007-08-20 11:37:10 UTC
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.

Comment 6 Marcela Mašláňová 2007-08-21 09:53:01 UTC
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.

Comment 7 Kostas Georgiou 2007-08-21 11:15:41 UTC
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?


Note You need to log in before you can comment on or make changes to this bug.