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

Status
Not open for further replies.

beye1850

IS-IT--Management
Jun 3, 2002
28
0
0
US
I am trying to setup a crontab that will will run once every other Thursday. For example it would run today October 24th and then again on Novemeber 7th then again on November 21st. ect...

So i really cant set it up by day of the month since it is always different and THU/2 does not seem to work like I wanted it to.

Thanks for any help.
 
What about 4/2 instead of thu/2? I haven't tested it, but maybe it will work.
 
How about you set this in your script?
date +%u (will give you day of the week)
date +%V ( will give you week of the year)

Say you want to run your script every thu all even week of the year and that is once every other thu.

if [`date+%u` = 4 && `date +%V/2 = 0 ] then
echo "hi"
fi

Patel
 
What about this -

1) Run your script every Thursday from the crontab.
2) The first time you run the script have it create a sentinel file (perhaps in /tmp) then do its normal processing
3) The next time it runs have it check for the presence of the sentinel file. If the file exists have the script delete the sentinel file then exit without any normal programming.
4) Next time the script runs the file will not be there and normal processing will occur as per step 2.

This will give you what you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top