diff options
author | sobomax <sobomax@FreeBSD.org> | 2012-10-17 20:45:48 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2012-10-17 20:45:48 +0000 |
commit | 53616179d3c7b797972066428db30596ca2f6802 (patch) | |
tree | 79a20cdc504be19c21e6ac0f9bd8399cd45f5fdb /usr.sbin/cron/cron | |
parent | da1e10945115230b209035b141dbdc01aa619d0a (diff) | |
download | FreeBSD-src-53616179d3c7b797972066428db30596ca2f6802.zip FreeBSD-src-53616179d3c7b797972066428db30596ca2f6802.tar.gz |
Revert latest changes to cron, until better version is worked out (I hope).
Requested by: few
Diffstat (limited to 'usr.sbin/cron/cron')
-rw-r--r-- | usr.sbin/cron/cron/cron.c | 26 | ||||
-rw-r--r-- | usr.sbin/cron/cron/cron.h | 6 |
2 files changed, 10 insertions, 22 deletions
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c index 5f3e7fd..9b4515c 100644 --- a/usr.sbin/cron/cron/cron.c +++ b/usr.sbin/cron/cron/cron.c @@ -98,7 +98,6 @@ main(argc, argv) char *argv[]; { cron_db database; - int runnum; ProgramName = argv[0]; @@ -150,24 +149,21 @@ main(argc, argv) load_database(&database); run_reboot_jobs(&database); cron_sync(); - runnum = 0; while (TRUE) { # if DEBUGGING /* if (!(DebugFlags & DTEST)) */ # endif /*DEBUGGING*/ cron_sleep(&database); - if (runnum % 60 == 0) - load_database(&database); + load_database(&database); /* do this iteration */ cron_tick(&database); - /* sleep 1 second + /* sleep 1 minute */ - TargetTime += 1; - runnum += 1; + TargetTime += 60; } } @@ -198,23 +194,22 @@ cron_tick(db) static time_t diff = 0, /* time difference in seconds from the last offset change */ difflimit = 0; /* end point for the time zone correction */ struct tm otztm; /* time in the old time zone */ - int otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow; + int otzminute, otzhour, otzdom, otzmonth, otzdow; register struct tm *tm = localtime(&TargetTime); - register int second, minute, hour, dom, month, dow; + register int minute, hour, dom, month, dow; register user *u; register entry *e; /* make 0-based values out of these so we can use them as indicies */ - second = tm->tm_sec -FIRST_SECOND; minute = tm->tm_min -FIRST_MINUTE; hour = tm->tm_hour -FIRST_HOUR; dom = tm->tm_mday -FIRST_DOM; month = tm->tm_mon +1 /* 0..11 -> 1..12 */ -FIRST_MONTH; dow = tm->tm_wday -FIRST_DOW; - Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d,%d)\n", - getpid(), second, minute, hour, dom, month, dow)) + Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d)\n", + getpid(), minute, hour, dom, month, dow)) if (dst_enabled && last_time != 0 && TargetTime > last_time /* exclude stepping back */ @@ -267,7 +262,6 @@ cron_tick(db) /* make 0-based values out of these so we can use them as indicies */ - otzsecond = otztm.tm_sec -FIRST_SECOND; otzminute = otztm.tm_min -FIRST_MINUTE; otzhour = otztm.tm_hour -FIRST_HOUR; otzdom = otztm.tm_mday -FIRST_DOM; @@ -289,8 +283,7 @@ cron_tick(db) e->uid, e->gid, e->cmd)) if ( diff != 0 && (e->flags & (RUN_AT|NOT_UNTIL)) ) { - if (bit_test(e->second, otzsecond) - && bit_test(e->minute, otzminute) + if (bit_test(e->minute, otzminute) && bit_test(e->hour, otzhour) && bit_test(e->month, otzmonth) && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR)) @@ -309,8 +302,7 @@ cron_tick(db) continue; } - if (bit_test(e->second, second) - && bit_test(e->minute, minute) + if (bit_test(e->minute, minute) && bit_test(e->hour, hour) && bit_test(e->month, month) && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR)) diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h index 387c72b..a2413cb 100644 --- a/usr.sbin/cron/cron/cron.h +++ b/usr.sbin/cron/cron/cron.h @@ -124,10 +124,6 @@ LineNumber = ln; \ } -#define FIRST_SECOND 0 -#define LAST_SECOND 59 -#define SECOND_COUNT (LAST_SECOND - FIRST_SECOND + 1) - #define FIRST_MINUTE 0 #define LAST_MINUTE 59 #define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1) @@ -169,7 +165,6 @@ typedef struct _entry { #endif char **envp; char *cmd; - bitstr_t bit_decl(second, SECOND_COUNT); bitstr_t bit_decl(minute, MINUTE_COUNT); bitstr_t bit_decl(hour, HOUR_COUNT); bitstr_t bit_decl(dom, DOM_COUNT); @@ -181,6 +176,7 @@ typedef struct _entry { #define WHEN_REBOOT 0x04 #define RUN_AT 0x08 #define NOT_UNTIL 0x10 +#define SECONDS_COUNT 0x20 time_t lastrun; } entry; |