Red Hat Bugzilla – Bug 295811
Impossible to create a run-parts that runs before cron.daily
Last modified: 2007-11-30 17:12:16 EST
Description of problem:
By default, 'run-parts /etc/cron.daily' happens at 4AM. In my environment, 4AM
is a "Good Time" to do the vast majority of the things dropped into
/etc/cron.daily. However, *some* things (such as log rotation) would be better
off at midnight (so we don't have 4 hours of each day's logs in some other day's
file). So, I created a /etc/cron.midnight, moved 'logrotate' from cron.daily to
cron.midnight, and added a line to /etc/crontab:
00 0 * * * root run-parts /etc/cron.midnight
To my surprise, this totally fails to fire. Why? Because it checks if
cron.daily has been run or not:
sh -vx /usr/bin/run-parts /etc/cron.midnight
# if cron.daily was run today
++ cat /var/spool/anacron/cron.daily
++ date +%Y%m%d
[ "$AUX1" == $AUX2 ] || exit 0
+ '[' 20070918 == 20070919 ']'
+ exit 0
It should only be checking the anacron timestamo for cron.daily if we are
actually running cron.daily.
Note that this is *NOT* self-inflicted error - the distributed cron.hourly
doesn't fire *either* between midnight and 4AM, for the exact same reason.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. 'run-parts /etc/cron.hourly' between midnight and when cron.daily runs
2. Watch nothing actually happen.
I've attached a patch that actually DTRT in run-parts. It may or may not be
desired to also add '0anacron' entries to other /etc/cron.<foo> directories, and
note that the /etc/cron.daily/0anacron script suffers from the same cron.daily
hardcoding issue, so the filename will need to be tweaked if you want 0anacron
for other run-parts directories.
Created attachment 199171 [details]
Patch to allow run-parts of other directories before /etc/cron.daily
I removed all checking of cron.daily has been (not) run. Is it now cron.midnight
working? Please upgrade on the new version of crontabs and anacron for test.
Should be fixed by the new version of anacron-2.3-56.fc8 & crontabs-1.10-18.fc8.