Bug 295811 - Impossible to create a run-parts that runs before cron.daily
Impossible to create a run-parts that runs before cron.daily
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: crontabs (Show other bugs)
rawhide
All Linux
low Severity low
: ---
: ---
Assigned To: Marcela Mašláňová
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-19 00:31 EDT by Valdis Kletnieks
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-10-17 02:57:01 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to allow run-parts of other directories before /etc/cron.daily (630 bytes, patch)
2007-09-19 00:31 EDT, Valdis Kletnieks
no flags Details | Diff

  None (edit)
Description Valdis Kletnieks 2007-09-19 00:31:06 EDT
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
#!/bin/bash
# if cron.daily was run today
AUX1=`cat /var/spool/anacron/cron.daily`
cat /var/spool/anacron/cron.daily
++ cat /var/spool/anacron/cron.daily
+ AUX1=20070918
AUX2=`date +%Y%m%d`
date +%Y%m%d
++ date +%Y%m%d
+ AUX2=20070919
[ "$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):
crontabs-1.10-17.fc8

How reproducible:


Steps to Reproduce:
1. 'run-parts /etc/cron.hourly' between midnight and when cron.daily runs
2. Watch nothing actually happen.
3.
  
Actual results:


Expected results:


Additional info:
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.
Comment 1 Valdis Kletnieks 2007-09-19 00:31:07 EDT
Created attachment 199171 [details]
Patch to allow run-parts of other directories before /etc/cron.daily
Comment 2 Marcela Mašláňová 2007-09-25 06:08:57 EDT
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.
Comment 3 Marcela Mašláňová 2007-10-17 02:57:01 EDT
Should be fixed by the new version of anacron-2.3-56.fc8 & crontabs-1.10-18.fc8.

Note You need to log in before you can comment on or make changes to this bug.