[ale] crontab

Jeff Lightner jlightner at water.com
Thu Apr 23 13:55:21 EDT 2009


That's pretty much what I did some time back when checking on Saturday.
This was ksh on HP-UX but ought to work with minimal tweaking for bash
on Linux.  

Note that this uses the "cal" (calendar) command and just cuts out a
specific column of dates - you'll have to adjust the cut for Thursday.

#
# Routine to verify this is being run on Saturday.   Error out if not.
#
if [ ! `date +%a` = "Sat" ]
then echo "ERROR:  This script is intended to be run on Saturday."
     exit 2
fi

#
# Routine to test for first Saturday of month.  If NOT the first
Saturday
# then abort this script.
#
DAYOFMONTH=`date +%e`
FINALSAT=`cal |cut -c19-20 |grep '[0-9]' |head -1`
# Output  a line separator and the date for the log
echo "=============================================================="
date
# Do the check
if [ $FINALSAT -ne $DAYOFMONTH ]
then echo "This is NOT the first Saturday of the month."
     else echo "This IS the first Saturday of the month."
fi

-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
Chris Fowler
Sent: Thursday, April 23, 2009 1:34 PM
To: ale at ale.org
Subject: [ale] crontab

I want to execute a script at 6pm on the first Thursday of each month.
Is there a trick in crontab I can do?

Here are the fields allowed

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sun, or use names)

The only thing I can think of off the top of my head is to run it every
Thursday and then check to see if we are the first Thursday of the
month. If not, exit 0.





_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
 
Please consider our environment before printing this e-mail or attachments.
----------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------



More information about the Ale mailing list