Hi,
in my previous e-mail I have attached patch version for wheezy with one
line missing what I found yesterday, applying the patch at next Debian
server.

I am attaching the corrected version, it works on Debian Wheezy. 

I think this patch, originally by Björn Danielsson, is of great value, when
it is necessary to keep some cron jobs strictly periodic in UTC and some
jobs synchronized with the local time. 

Sorry for sending faulty patch in my previous mail.

Best regards,
PAD
-- 
/**************************************************************************
 Dr Piotr A. Dybczynski, Astronomical Observatory, A.Mickiewicz University 
 homepage: http://apollo.astro.amu.edu.pl/PAD     e-mail: dy...@amu.edu.pl
********************************************************************PAD***/
*** entry.c~    Wed Nov 26 18:37:08 2003
--- entry.c     Wed Nov 26 18:46:17 2003
***************
*** 310,313 ****
--- 310,317 ----
        }
  #endif
+       {
+         char *utc = env_get("CRONTAB_UTC", e->envp);
+         if (utc && atoi(utc)) { e->flags |= CRONTAB_UTC; }
+       }
  
        Debug(DPARS, ("load_entry()...about to parse command\n"))
*** cron.h~     Wed Nov 26 18:37:08 2003
--- cron.h      Wed Nov 26 18:47:09 2003
***************
*** 187,190 ****
--- 187,191 ----
  #define MIN_STAR      0x08
  #define HR_STAR               0x10
+ #define CRONTAB_UTC   0x4000
  } entry;
  
*** cron.c~     Wed Nov 26 18:37:08 2003
--- cron.c      Wed Nov 26 19:00:52 2003
***************
*** 331,335 ****
--- 331,337 ----
        register user           *u;
        register entry          *e;
+       register int            utcflag = 0;
  
+  again:
        /* make 0-based values out of these so we can use them as indicies
         */
***************
*** 352,355 ****
--- 354,358 ----
        for (u = db->head;  u != NULL;  u = u->next) {
                for (e = u->crontab;  e != NULL;  e = e->next) {
+                 if ((e->flags & CRONTAB_UTC) == utcflag) {
                        Debug(DSCH|DEXT, ("user [%s:%d:%d:...] cmd=\"%s\"\n",
                            env_get("LOGNAME", e->envp),
***************
*** 365,369 ****
--- 368,381 ----
                                        job_add(e, u);
                        }
+                 }
                }
+       }
+       /* run the above code once again, but now with utcflag non-zero and
+        * tm set to GMT instead of local time.
+        */
+       if (!utcflag) {
+         utcflag = CRONTAB_UTC;
+         virtualSecond -= GMToff;
+         tm = gmtime(&virtualSecond);
+         goto again;
        }
  }

Reply via email to