It seems the original author of crond slightly messed up the logic for checking whether the current time matches the time that was specified. This patch fixes it.
For some reason there was an OR where there should have been an AND, which meant if the time and day of month OR the month and day of week match the current time, the job would run. So you'd get jobs running every minute if the day of week and month match. And if they didn't match, you'd still get the job running if the time and day of month match. Also, in the tm struct, the day of the month (tm_mday) starts at 1, not the month (tm_mon).
diff --git a/toys/pending/crond.c b/toys/pending/crond.c index ac96061d..8fef1148 100644 --- a/toys/pending/crond.c +++ b/toys/pending/crond.c @@ -604,8 +604,8 @@ static void schedule_jobs(time_t ctime, time_t ptime) if (TT.flagd) loginfo(LOG_LEVEL5, " line %s", job->cmd); if (job->min[lt->tm_min] && job->hour[lt->tm_hour] - && (job->dom[lt->tm_mday] || job->dow[lt->tm_wday]) - && job->mon[lt->tm_mon-1]) { + && (job->dom[lt->tm_mday-1] && job->dow[lt->tm_wday]) + && job->mon[lt->tm_mon]) { if (TT.flagd) loginfo(LOG_LEVEL5, " job: %d %s\n", (int)job->pid, job->cmd); if (job->pid > 0) {
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net