#!/bin/sh # # $Header: /home/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons,v 1.5 2002/06/23 17:37:19 bangert Exp $ # # 23 Jun 2002; Jon Nelson run-crons: # # fixed a race condition, where cron jobs and run-crons wanted to delete # touch files # # 20 Apr 2002; Thilo Bangert run-crons: # # moved lastrun directory to /var/spool/cron/lastrun # # Author: Achim Gottinger # # 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 mkdir -p /var/spool/cron/lastrun # for BASE in hourly daily weekly monthly do CRONDIR=/etc/cron.${BASE} test -d $CRONDIR || continue if test -e /var/spool/cron/lastrun/cron.$BASE then case $BASE in hourly) #>= 65 min -=> +64 min TIME="-cmin +64" ;; daily) #>= 1 day, 5 min -=> +1444 min TIME="-cmin +1444" ;; weekly) #>= 1 week, 5 min -=> +10084 min TIME="-cmin +10085" ;; monthly) #>= 30 days, 5 min -=> +43204 min TIME="-cmin +43204" ;; esac find /var/spool/cron/lastrun/cron.$BASE $TIME -exec rm {} \; fi # if there is no touch file, make one then run the scripts if test ! -f /var/spool/cron/lastrun/cron.$BASE then touch /var/spool/cron/lastrun/cron.$BASE set +e for SCRIPT in $CRONDIR/* do test -d $SCRIPT && continue if test -x $SCRIPT ; then $SCRIPT fi done fi done # touch /var/spool/cron/lastrun find /var/spool/cron/lastrun -newer /var/spool/cron/lastrun -exec /bin/rm -f {} \;