From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653652421688.tru64-unix-managers.marc@archive.invalid> From: Boddy Bill - bboddy Date: Thu, 05 Jul 2001 15:24:16 +0000 To: tru64-unix-managers Subject: SUMMARY: cron - do something on the first Saturday of a month X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653652421688 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------_=_NextPart_001_01C10566.461B0124" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C10566.461B0124 Content-Type: text/plain; charset="iso-8859-1" Thanks to 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. ------_=_NextPart_001_01C10566.461B0124 Content-Type: text/html; charset="iso-8859-1"
Thanks to  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.
------_=_NextPart_001_01C10566.461B0124--