#!/bin/sh . /etc/rc.common ## ## Usage: doPeriodic Arg1 Arg2 Arg3 ## Description: ## Arg1 --> logfile e.g., /var/log/daily.out ## Arg2 --> search pattern ## Arg3 --> periodic arg e.g., daily ## doPeriodic() { ifRan="" if [ -f "$1" ]; then ifRan=`cat $1 | grep -e "$2"` fi if [ -z "$ifRan" ]; then ConsoleMessage "Running Periodic $3" /usr/sbin/periodic $3 fi } aYear=`date '+%Y'` thisHour=`date '+%k'` thisMin=`date '+%M'` thisDay=`date '+%e'` ## ## Daily ## aLog="/var/log/daily.out" aDate=`date '+%a %b %e'` ptn="$aDate 03:15:01 EST $aYear" # don't run too early in the morning # the normal cron job runs at 03:15:01 if [ $thisHour -eq 3 ] && [ $thisMin -gt 15 ] || [ $thisHour -gt 3 ]; then doPeriodic "$aLog" "$ptn" "daily" fi ## ## Weekly ## aLog="/var/log/weekly.out" aWeek=`date '+%U'` ptn="Year:$aYear Week:$aWeek" # weekly is normally run on Sunday (via cron) # so we'll run if it was skipped if [ `date '+%a'` != "Sun" ]; then doPeriodic "$aLog" "$ptn" "weekly" fi ## ## Monthly ## aLog="/var/log/monthly.out" aMonth=`date '+%b'` ptn="[A-Za-z]\+ $aMonth [0-9]\+ [0-9:]\+ [A-Z]\+ $aYear" # monthly is normally run at the first of the month # if it skips we'll pick this up in a few days if [ $thisDay -gt 5 ]; then doPeriodic "$aLog" "$ptn" "monthly" fi