tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY:  cron - do something on the first Saturday of a month
@ 2001-07-05 15:24 Boddy Bill - bboddy
  0 siblings, 0 replies; only message in thread
From: Boddy Bill - bboddy @ 2001-07-05 15:24 UTC (permalink / raw)
  To: tru64-unix-managers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------_=_NextPart_001_01C10566.461B0124", Size: 11309 bytes --]

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   <mailto:William_Bochnik@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.



------_=_NextPart_001_01C10566.461B0124
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face="Bookman Old Style" size=2><SPAN class=500131415-05072001><FONT 
color=#000080>Thanks to<U>&nbsp; </U></FONT><A 
href="mailto:William_Bochnik@acml.com"></A><FONT color=#000080>Larye D. Parkins 
and William Bochnik who both advised that</FONT></SPAN></FONT><FONT size=2><FONT 
color=#000080 face="Bookman Old Style"><SPAN class=500131415-05072001>&nbsp; 
cron works as an "or " and not as an " and "</SPAN></FONT></FONT></DIV>
<DIV><SPAN class=500131415-05072001></SPAN><FONT size=2><FONT color=#000080 
face="Bookman Old Style"><SPAN class=500131415-05072001>Thereby by cron line 
would work on every Saturday and also every 1st to the 7th of the month at 
00:01</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Bookman Old Style"><SPAN 
class=500131415-05072001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT color=#000080 face="Bookman Old Style"><SPAN 
class=500131415-05072001>Though <STRONG>Dan Danielson&nbsp;</STRONG>, went even 
further and provided a wrapper for the cron command.</SPAN></FONT></FONT></DIV>
<DIV><FONT face="Bookman Old Style"><FONT size=2><FONT face=Arial><SPAN 
class=681561313-05072001><SPAN class=500131415-05072001><FONT color=#000080 
face="Bookman Old Style">&nbsp;</FONT></SPAN></SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT color=#000080><FONT face="Bookman Old Style"><FONT size=2><FONT 
color=#800000 face=Arial><SPAN 
class=681561313-05072001>#!/bin/sh</SPAN></FONT></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN class=681561313-05072001># 
<STRONG>whichweek.sh</STRONG>: run a command on a given week of the 
month</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>#&nbsp;&nbsp;&nbsp;&nbsp;$1 is the week 
number</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>#&nbsp;&nbsp;&nbsp;&nbsp;$2 ..... $n are the commands 
to be run</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>week=$1</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>shift</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>command=$*</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN class=681561313-05072001># get 
today's date</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>today=`date +%d`</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN class=681561313-05072001># 
figure when week beguins and ends</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>startdate=`expr \( $week - 1 \) \* 7 + 
1`</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>enddate=`expr $week \* 7`</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN class=681561313-05072001>if 
[&nbsp;$today -lt $startdate -o $today -gt $enddate&nbsp;]; then exit 0; 
fi</SPAN></FONT></DIV>
<DIV><FONT color=#800000 face=Arial size=2><SPAN 
class=681561313-05072001>$command</SPAN></FONT></DIV>
<DIV><FONT face=Arial><SPAN class=681561313-05072001></SPAN></FONT><FONT 
size=2>&nbsp;</FONT></DIV>
<DIV><FONT face=Arial><SPAN class=681561313-05072001></SPAN></FONT><FONT 
size=2>&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><EM><FONT size=2><SPAN class=500131415-05072001>Therefore my</SPAN><FONT 
face=Arial><SPAN class=681561313-05072001><FONT face="Bookman Old Style"><SPAN 
class=500131415-05072001>&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
class=500131415-05072001>&nbsp;c</SPAN></FONT>ron entry would look like<FONT 
face="Bookman Old Style"><SPAN 
class=500131415-05072001>&nbsp;.......</SPAN></FONT></SPAN></FONT></FONT></EM></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=681561313-05072001><FONT 
face="Bookman Old Style"><SPAN 
class=500131415-05072001></SPAN></FONT></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><EM><FONT size=2><FONT face=Arial><SPAN class=681561313-05072001><FONT 
face="Bookman Old Style"><SPAN 
class=500131415-05072001>&nbsp;</SPAN></FONT></SPAN></FONT></FONT></EM></DIV>
<DIV><STRONG><EM><FONT face=Arial size=2><SPAN class=681561313-05072001># Run on 
first Saturday of the month</SPAN></FONT></EM></STRONG></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=681561313-05072001><EM><STRONG>1&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 
*&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp; whichweek.sh 1 
command</STRONG></EM></SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN 
class=500131415-05072001><EM>&nbsp;</EM></SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=500131415-05072001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2><SPAN class=500131415-05072001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2><EM><FONT color=#800000><SPAN class=500131415-05072001><FONT 
face=Arial>POST..............</FONT>&nbsp;</SPAN><BR></FONT></EM></DIV></FONT></FONT></FONT>
<BLOCKQUOTE>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>Hi</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>I would like to run a script on the first Saturday of 
  every month.</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>Would the following work ?</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000080 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>1&nbsp;&nbsp;&nbsp;&nbsp; 
  0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1-7&nbsp;&nbsp;&nbsp;&nbsp; 
  *&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp; 
command</SPAN></FONT></DIV>
  <DIV><FONT color=#000080 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000080 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000080 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>i.e.&nbsp; Run the command at 00:01 on every Saturday 
  , as long as it was between the 1st and the 7th of the 
  month.</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>Normally , I would test this, but I don't have a 
  box&nbsp; that I could change the time/date over a short test 
  period.</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001>regards</SPAN></FONT></DIV>
  <DIV><FONT color=#800000 face="Bookman Old Style" size=2><SPAN 
  class=750423909-05072001></SPAN></FONT>&nbsp;</DIV>
  <P><FONT color=#800000 face="Bookman Old Style" size=2>Bill 
  Boddy</FONT>&nbsp;<BR><FONT color=#800000 face="Bookman Old Style" 
  size=2><SPAN class=750423909-05072001></SPAN></FONT></P>
  <DIV>&nbsp;</DIV><CODE><FONT size=3><BR><BR>The information contained in this 
  communication is<BR>confidential, is intended only for the use of the 
  recipient<BR>named above, and may be legally privileged. If the reader <BR>of 
  this message is not the intended recipient, you are<BR>hereby notified that 
  any dissemination, distribution or<BR>copying of this communication is 
  strictly prohibited. <BR>If you have received this communication in error, 
  please <BR>re-send this communication to the sender and delete the 
  <BR>original message or any copy of it from your 
computer<BR>system.<BR></BLOCKQUOTE></FONT></CODE></BODY></HTML>

------_=_NextPart_001_01C10566.461B0124--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-07-05 15:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-05 15:24 SUMMARY: cron - do something on the first Saturday of a month Boddy Bill - bboddy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox