Bug 295811

Summary: Impossible to create a run-parts that runs before cron.daily
Product: [Fedora] Fedora Reporter: Valdis Kletnieks <valdis.kletnieks>
Component: crontabsAssignee: Marcela Mašláňová <mmaslano>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-17 06:57:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to allow run-parts of other directories before /etc/cron.daily none

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.