#!/bin/ksh # @(#) Work with crontab #..# systems: #..# sites: tag=${0##*/} tmp=/tmp/${tag}$$ rm -f $tmp usage="Usage: $tag [-w] [-m] " while [ $# -gt 0 ]; do case "$1" in -v|-x) set "$1" ;; -vi) vi $0; exit ;; -about) echo "$tag was written by David Ledger" echo "dledger@ivdcs.demon.co.uk" exit ;; -h) echo "" echo "$usage" echo "" echo "$tag edits a users crontab file, changing the first line" echo "that would be found by an 'ed' // search. The time" echo "on that line is changed to be 1 minute ahead of the" echo "current time. If '-w' is given, after the edit and re-" echo "submission to cron, the script sleeps until the next" echo "munute before exiting. If '-m' is specified, the same" echo "wait is made, and after a further second, 'mailx' is" echo "invoked to read the mail resulting from the cron job." echo "" echo "" echo "" exit ;; -w*) wait=1 ;; -m*) wait=1; mail=1 ;; *) job=$1 ;; esac shift done [ "$job" ] || { print "$usage"; print "Need to specify cron job"; exit; } nxtmin() { set -A nm $* [ ${nm[4]} -lt 59 ] && nm[4]=$((nm[4] + 1)) || { [ ${nm[3]} -lt 23 ] && { nm[3]=$((nm[3] + 1)) nm[4]=0 } || { nm[3]=0 nm[4]=0 } } echo ${nm[*]} } set -A dt `date "+%y %m %d %H %M %S"` [ ${dt[5]} -gt 58 ] && { sleep 2 set -A dt `date "+%y %m %d %H %M %S"` } echo ${dt[*]} set -A nm `nxtmin ${dt[*]}` crontab -l $tmp ed $tmp | |