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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a cron job second saturday of the month

Status
Not open for further replies.

umeman

Technical User
Oct 2, 2001
59
US

I need help with the following:
I am trying to run a cron job on the second saturday of each month, but I cannot figure out the cron table settings

If you have done something similar, please share your ideas,

Thanks
All help appreciated

-U-

 
The only way i know to do this is to set up your cron for every Saturday. The cron then calls a script which checks if it is the second saturday of the month.
How does the script work ? Well, the second saturday must lie between the 8th and the 14th

So you script needs to say something like :-

day=`date +%d`
If $day >7 and <15 then .... execute your next script
else do nothing.

Post back if you need further help with the script
 
if you run the job every saturday then you can calculate the week in your script with something like:

cal | awk '{s=&quot; &quot;$0&quot; &quot;}s~/ '`date +%d|sed s/^0\*//`' /{print NR-2}'

then if week number is 1 first saturday if is 2 second saturday and so one ..

Hope it helps,

Carlos Almeida


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top