advertisements
_____________________________________________________________________________________________________________________
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
_____________________________________________________________________________________________________________________
0 comments:
Post a Comment