Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crontab Run every 2nd Saturday of month 1

Status
Not open for further replies.

smicro

MIS
Dec 26, 2002
281
0
0
US
Is there a way to run a job through cron only on the second saturday of early month. I have a job I need to run at 6AM on the second Saturday of every month.
0 6 * * 6 would get me every Saturday of the month but I needed only the second Saturday. Any help would be great, thanks!
 
Within the script started by cron every Saturday, use the 'date' command to find out the day-of-the-month, and exit the script without doing anything if it is not between 8 and 14.

If the 1st of the Month is Saturday (earliest case), the second Saturday will be the 8th, and if the 1st of the month is Sunday (latest case), the second Saturday will be the 14th.
 
Here's the script in detail:

#
# define an integer parameter
typeset -i x
#
# set the integer to the day-of-the-month
x=`date +%d`
#
# if x >= 8 and x <= 14, do something or other...
if [ $x -ge 8 -a $x -le 14 ]
then
# your process goes here
echo "do the real thing"
fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top