CRON runs things twice (SUMMARY)

Chris Rende car at trux.UUCP
Thu Mar 8 02:42:55 AEST 1990


Thanks to all those who either posted or Emailed responses regarding
the problem with CRON running things twice.

The bottom line is that there is a bug in the AT&T System V CRON. It may
have been fixed in more recent releases.

The bug manifests itself by running something 1 second early and then AGAIN
at the proper time.

The following are NOT the cause of this particular problem:

- Change of date/time either with date(1) or with BSD's adjtime(2).
  (nada.kth.se!paf)
- Two CRON's running at the same time. (mcorrigan at ucsd.edu)
- NNTP or TIMED (hedrick at athos.rutgers.edu)

A few other notes which people sent to me:

- Even the System V Release 3 CRON is reported to get messed up by date/time
  changes while CRON is running. (motcsd!brian)
- This same bug also exists under SunOS 4.0.3 (bugids 1022379 and 1027075).
  (ata!eggert)
- It's a known bug in the AT&T system. (keith at bain3.oz)
- Observered frequency is once every 1-2 months. (keith at bain3.oz)
- It is rumored to be fixed in OSx5. (keith at bain3.oz)
- It is estimated that twice per hour CRON goofs up some where in the world.
  (keith at bain3.oz)

Suggested solutions:

- Run the UCB CRON instead of the ATT CRON. (ejp at bohra.cpg.oz)
- Use lock files in your jobs. (ejp at bohra.cpg.oz)

Here is a good summary and a fix from vogon.cetia.fr!philip:

Most SV Rel. 2 systems share your problem.
It seems to be that the (twisted) logic of cron takes the time
several times during execution, and it is very lax in which one of
the values obtained it actually believes.

Rather than try to corect the logic, I have used a fix, which cures
the problem, but has a side effect that *some* commands may be
run one second late. I find this acceptable, since one second is within
the normal scheduling tolerances of UNIX.

I hope you have access to the sources, because here is a context
diff showing my modificaton:

*** cron.c	Thu Jan  4 12:26:40 1990
--- cron.c.orig	Tue Mar  6 10:33:59 1990
***************
*** 239,245
  #endif
  		seconds = (ne_time < (long) 0) ? (long) 0 : ne_time;
  		if(ne_time > (long) 0)
! 			idle(seconds == 1L ? 2L : seconds);
  		if(notexpired) {
  			notexpired = 0;
  			last_time = INFINITY;

--- 239,245 -----
  #endif
  		seconds = (ne_time < (long) 0) ? (long) 0 : ne_time;
  		if(ne_time > (long) 0)
! 			idle(seconds);
  		if(notexpired) {
  			notexpired = 0;
  			last_time = INFINITY;

I suppose that on a really slow system, you may need to change the 2L
into 3L - but that would be a *slow* machine.

---------------

car.
-- 
Christopher A. Rende           Central Cartage (Nixdorf/Pyramid/SysVR2/BSD4.3)
uunet!edsews!rphroy!trux!car   Multics,DTSS,Unix,Shortwave,Scanners,StarTrek
 trux!car at uunet.uu.net         Minix 1.2,PC/XT,Mac+,TRS-80 Model I,1802 ELF
       "I don't ever remember forgetting anything." - Chris Rende



More information about the Comp.sys.pyramid mailing list