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

Advanced Cron programming help needed

Status
Not open for further replies.

sbellmore01

IS-IT--Management
May 5, 2004
7
US
So using Cron on a linux box is a very handy tool. However, i'm trying to run a job on the first sunday of every month. And I'm not sure if it can be done. Using Legato schedules this can be accomplished quite easily but not with just linux.

Any help on the syntax of running a cron job on the First Sunday of Every Month would be greatly appreciated.
 
You could try this, not sure if it works:

* * 1-7 * 0 /command/to/run
 
Hello,

this question has been asked on Unix/Linux forums quite a number of times.
Unfortunately GunnarD's solution will not work; it will run the program every sunday, and on the first 7 days of each month.

A common workaround is this:
Write a script that first has to check (via date +%d) if the day of the month is less than 8; if not so, the script will have to exit.
Then run this script in cron every sunday.

regards
 
It should work but it does not! :(

Does anyone have a clue why not?
 
You could try this:

0 1 1-7 * * [ $(date "+\%a") = "\Sun" ] && echo "the first Sunday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top