Thanks to <mailto:William_Bochnik_at_acml.com> Larye D. Parkins and William
Bochnik who both advised that cron works as an "or " and not as an " and "
Thereby by cron line would work on every Saturday and also every 1st to the
7th of the month at 00:01
Though Dan Danielson , went even further and provided a wrapper for the cron
command.
#!/bin/sh
# whichweek.sh: run a command on a given week of the month
# $1 is the week number
# $2 ..... $n are the commands to be run
week=$1
shift
command=$*
# get today's date
today=`date +%d`
# figure when week beguins and ends
startdate=`expr \( $week - 1 \) \* 7 + 1`
enddate=`expr $week \* 7`
if [ $today -lt $startdate -o $today -gt $enddate ]; then exit 0; fi
$command
Therefore my cron entry would look like .......
# Run on first Saturday of the month
1 0 * * 6 whichweek.sh 1 command
POST..............
Hi
I would like to run a script on the first Saturday of every month.
Would the following work ?
1 0 1-7 * 6 command
i.e. Run the command at 00:01 on every Saturday , as long as it was between
the 1st and the 7th of the month.
Normally , I would test this, but I don't have a box that I could change
the time/date over a short test period.
regards
Bill Boddy
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged. If the reader
of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.
If you have received this communication in error, please
re-send this communication to the sender and delete the
original message or any copy of it from your computer
system.
Received on Thu Jul 05 2001 - 15:25:23 NZST