dcron
dcron copied to clipboard
@daily @hourly etc not run
After merging of #3, my @daily @hourly etc jobs are not run. I've reverted back to 6186237 and they are run again.
I can confirm this is still an issue 3 years later.
Would be nice to see support for these. as well as @reboot
The problem is that the manual mentions the options but they do not work:
As a workaround add something like this in your system crontab file:
# SYSTEM HOURLY/DAILY/WEEKLY/MONTHLY FOLDERS 0 * * * * /bin/run-parts /etc/cron.hourly 0 3 * * * /bin/run-parts /etc/cron.daily 15 4 * * 6 /bin/run-parts /etc/cron.weekly 30 5 1 * * /bin/run-parts /etc/cron.monthly
The issue is that for aliases like @hourly, @daily, etc. any point in time (minute, hour, day of month, month: * * * * ) will be allowed for processing in SynchronizeFile() (database.c:448) and the actual execution of the job only depends on the "frequency" (i.e. 60x60 for hourly, 24x60x60 for daily, etc.). Initialization for day-of-week (dow) though, is apparently missing! In TestJobs() (database:1032) and ArmJob() (database.c:1105) there is a check that involves day-of-week that consequently fails, so the job will never be run. (Additional debug output by me.)
cron.debug crond[21448]: Synchronizing /etc/cron.d
cron.debug crond[21448]: User root Entry @hourly ID=sys-hourly /bin/run-parts /etc/cron.hourly
cron.debug crond[21448]: Command /bin/run-parts /etc/cron.hourly Job sys-hourly
cron.debug crond[21448]: SynchronizeFile():
cron.debug crond[21448]: CronLine: ------------
cron.debug crond[21448]: Command: /bin/run-parts /etc/cron.hourly
cron.debug crond[21448]: Freq: 3600 (seconds)
cron.debug crond[21448]: Delay: 180
cron.debug crond[21448]: PID: 0
cron.debug crond[21448]: Mins: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Hrs: xxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Days: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Mons: xxxxxxxxxxxx
cron.debug crond[21448]: Dow: 00 00 00 00 00 00 00
[...]
cron.debug crond[21448]: TestStartup for FILE /etc/cron.d/system USER root:
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.hourly JOB sys-hourly
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.daily JOB sys-daily
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.weekly JOB sys-weekly
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.monthly JOB sys-monthly
cron.debug crond[21448]: Wakeup dt=33
cron.debug crond[21448]: TestJobs() database.c:976
cron.debug crond[21448]: Wakeup dt=60
cron.debug crond[21448]: TestJobs() database.c:976
cron.debug crond[21448]: Wakeup dt=60
cron.debug crond[21448]: TestJobs() database.c:976
[...]
To make the aliases work, I added the following two lines to SynchronizeFile() (database.c:458):
for (j=0; j<7; ++j)
line.cl_Dow[j] = ALL_DOW;
Then the debug messages look like:
cron.debug crond[21448]: Synchronizing /etc/cron.d
cron.debug crond[21448]: User root Entry @hourly ID=sys-hourly /bin/run-parts /etc/cron.hourly
cron.debug crond[21448]: Command /bin/run-parts /etc/cron.hourly Job sys-hourly
cron.debug crond[21448]: SynchronizeFile():
cron.debug crond[21448]: CronLine: ------------
cron.debug crond[21448]: Command: /bin/run-parts /etc/cron.hourly
cron.debug crond[21448]: Freq: 3600 (seconds)
cron.debug crond[21448]: Delay: 180
cron.debug crond[21448]: PID: 0
cron.debug crond[21448]: Mins: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Hrs: xxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Days: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cron.debug crond[21448]: Mons: xxxxxxxxxxxx
cron.debug crond[21448]: Dow: 3f 3f 3f 3f 3f 3f 3f
[...]
cron.debug crond[21448]: TestStartup for FILE /etc/cron.d/system USER root:
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.hourly JOB sys-hourly
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.daily JOB sys-daily
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.weekly JOB sys-weekly
cron.debug crond[21448]: LINE /bin/run-parts /etc/cron.monthly JOB sys-monthly
cron.debug crond[6802]: Wakeup dt=50
cron.debug crond[6802]: TestJobs() database.c:976
cron.debug crond[6802]: Wakeup dt=60
cron.debug crond[6802]: TestJobs() database.c:976
cron.debug crond[6802]: Wakeup dt=60
cron.debug crond[6802]: TestJobs() database.c:976
cron.debug crond[6802]: ArmJob(): sys-hourly
cron.debug crond[6802]: scheduled: user root job sys-hourly
cron.debug crond[6802]: RunJobs(): sys-hourly
cron.info crond[6802]: FILE /etc/cron.d/system USER root PID 7772 job sys-hourly
cron.debug crond[6802]: RunJobs(): sys-daily
cron.debug crond[6802]: RunJobs(): sys-weekly
cron.debug crond[6802]: RunJobs(): sys-monthly
cron.debug crond[9198]: child running: job sys-hourly
cron.debug crond[6802]: exit status 0 from user root job sys-hourly
[...]
But @henri62's workaround (explicitely using time tables instead of aliases) will certainly do.