Bug 199220 - cron upgrade reruns @reboot jobs
cron upgrade reruns @reboot jobs
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: vixie-cron (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Marcela Mašláňová
Brock Organ
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-17 23:29 EDT by Andrew Baumann
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-08-20 03:32:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Andrew Baumann 2006-07-17 23:29:55 EDT
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 11:28:25 EDT
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 19:45:06 EDT
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 06:59:33 EDT
Could be future feature - moving to devel.
Comment 4 Marcela Mašláňová 2007-08-20 03:32:46 EDT
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 07:37:10 EDT
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 05:53:01 EDT
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 07:15:41 EDT
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.