Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 106105 Details for
Bug 69777
sys-process/cronbase: /etc/crontab deletion of lastrun files causes run-crons to execute more often than it should
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
proposed fix for run-crons.
run-crons (text/plain), 3.31 KB, created by
Peter Volkov (RETIRED)
on 2007-01-08 20:41:11 UTC
(
hide
)
Description:
proposed fix for run-crons.
Filename:
MIME Type:
Creator:
Peter Volkov (RETIRED)
Created:
2007-01-08 20:41:11 UTC
Size:
3.31 KB
patch
obsolete
>#!/bin/bash ># ># $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3.2,v 1.1 2005/03/09 12:51:34 ka0ttic Exp $ ># ># 08 Jan 2007; Volkov Peter <pva@gentoo.org> run-crons: ># Use seconds since the epoch (date +%s) instead of time stamps to avoid ># running crons twice caused by daylight saving time change. ># ># 08 Mar 2005; Aaron Walker <ka0ttic@gentoo.org> run-crons: ># Ignore the error messages from find caused by race conditions, since ># we could care less about the error as long as the file has been removed. ># See bug 8506. ># ># 06 May 2004; Aron Griffis <agriffis@gentoo.org> run-crons: ># Make the locking actually work. The old code was racy. ># Thanks to Mathias Gumz in bug 45155 for some cleanups. ># ># 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: ># fixed a race condition, where cron jobs and run-crons wanted to ># delete touch files ># ># 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons: ># moved lastrun directory to /var/spool/cron/lastrun ># ># Author: Achim Gottinger <achim@gentoo.org> ># ># Mostly copied from SuSE ># ># this script looks into /etc/cron.[hourly|daily|weekly|monthly] ># for scripts to be executed. The info about last run is stored in ># /var/spool/cron/lastrun > >LOCKDIR=/var/spool/cron/lastrun >LOCKFILE=${LOCKDIR}/lock > >mkdir -p ${LOCKDIR} > ># Make sure we're not running multiple instances at once. ># Try twice to lock, otherwise give up. >for ((i = 0; i < 2; i = i + 1)); do > ln -sn $$ ${LOCKFILE} 2>/dev/null && break > > # lock failed, check for a running process. > # handle both old- and new-style locking. > cronpid=$(readlink ${LOCKFILE} 2>/dev/null) || > cronpid=$(cat ${LOCKFILE} 2>/dev/null) || > continue # lockfile disappeared? try again > > # better than kill -0 because we can verify that it's really > # another run-crons process > if [[ $(</proc/${cronpid}/cmdline) == $(</proc/$$/cmdline) ]] 2>/dev/null; then > # whoa, another process is really running > exit 0 > else > rm -f ${LOCKFILE} > fi >done > ># Check to make sure locking was successful >if [[ ! -L ${LOCKFILE} ]]; then > echo "Can't create or read existing ${LOCKFILE}, giving up" > exit 1 >fi > ># Set a trap to remove the lockfile when we're finished >trap "rm -f ${LOCKFILE}" 0 1 2 3 15 > >CUR_TIME=`date +%s` > >for BASE in hourly daily weekly monthly >do > CRONDIR=/etc/cron.${BASE} > > test -d $CRONDIR || continue > > if [ -e ${LOCKDIR}/cron.$BASE ] > then > case $BASE in > hourly) > # 1 hour -=> 60 min = 3600 sec > TIME=$(( ${CUR_TIME} - 3600 )) ;; > daily) > # 1 day -=> +1440 min = 86400 sec > TIME=$(( ${CUR_TIME} - 86400 )) ;; > weekly) > # 1 week -=> +10080 min = 604800 sec > TIME=$(( ${CUR_TIME} - 604800 )) ;; > monthly) > # 31 days -=> +44640 min = 2678400 sec > TIME=$(( ${CUR_TIME} - 2678400 )) ;; > esac > [ $(<${LOCKDIR}/cron.${BASE}) -lt ${TIME} ] && rm ${LOCKDIR}/cron.${BASE} > fi > > # if there is no touch file, make one then run the scripts > if [ ! -e ${LOCKDIR}/cron.$BASE ] > then > echo ${CUR_TIME} > ${LOCKDIR}/cron.$BASE > > set +e > for SCRIPT in $CRONDIR/* > do > if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then > $SCRIPT > fi > done > fi >done > ># Clean out bogus cron.$BASE files with future times >CUR_TIME=`date +%s` >for cronfile in ${LOCKDIR}/cron.* >do > [ $(<${cronfile}) -gt ${CUR_TIME} ] && rm ${cronfile} >done
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 69777
:
106105
|
106173
|
500786