How to schedule a Unix shell script in crontab to run every 2nd Saturday(nth Day of the month)

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
There is no direct way to schedule the script in crontab for nth day of every month. Which means suppose if you wanted to execute the shell script for every 2nd Saturday or every 3rd Monday, etc. (i.e: The execution occurrence will be one in a month; nth Sunday, Monday, Teusday, Wednesday, Thursday, Friday or Saturday) Crontab will not support this. You have to write your own code to execute this. A sample code is given below.
TODAY=`/bin/date +%d | cut -d"0" -f2`
DAY=`cal | awk {'print $7'} | xargs | /usr/bin/cut -d" " -f3`
#See if today matches the 2nd Tuesday of the month
if [ "$TODAY" -ne "$DAY" ] ; then
echo "Today is not Second Saturday"
else
echo "Today is 2nd Saturday. Please put your program code just below."
fi

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer