Bug 295811 - Impossible to create a run-parts that runs before cron.daily
Summary: Impossible to create a run-parts that runs before cron.daily
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: crontabs
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-09-19 04:31 UTC by Valdis Kletnieks
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2007-10-17 06:57:01 UTC
Type: ---
Embargoed:


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

Description Valdis Kletnieks 2007-09-19 04:31:06 UTC
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 04:31:07 UTC
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 10:08:57 UTC
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 06:57:01 UTC
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.