Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

how to create a cron job that run in first day of the month , every 3 months.?

thanks

share|improve this question
2  
What's this got to do with Apache 2? –  Jawa Apr 6 '10 at 11:25

2 Answers 2

up vote 14 down vote accepted

The following will run script on the 1st of Jan, Apr, Jul and Oct at 03:30

30 03 01 Jan,Apr,Jul,Oct * /path/to/script

Alternatively, but less obvious

30 03 01 */3 * /path/to/script

Will run every three months at 03:30 on the 1st of Jan,Apr,Jul and Oct.

share|improve this answer
1  
+1: I always thought the / notation was the MOST obvious...I use it wherever possible. (Words in the scheduling part of the crontab freak me out...I'd do: "0 0 1 3,6,9,12 * /path/to/script.bash" if I couldn't do /3) –  Satanicpuppy Apr 6 '10 at 14:27

Wikipedia has a nice explanation about how to configure Cron.

For your specific case you could run a Cron Expression to run every 3 months- obviously change the months to suit your schedule.

0 0 1 JAN,APR,JUL,OCT  * /path/to/script.bash
share|improve this answer
1  
-1 Whilst this has been marked correct answer, it will error as the fields are in the wrong order and even if they were in the correct order would run every day at midnight through Jan, Apr, Jul, Oct (eg 01/01 02/01 ... 31/01 01/04 ..) and not just once every three months. My answer would work but was not accepted. Sad me! –  Richard Holloway Apr 6 '10 at 6:36
    
@Richard Holloway - the mysteries of server fault - have updated my answer thanks for pointing out the typo –  Jon Rhoades Apr 6 '10 at 6:55
    
I have removed my -1 to reflect the change. –  Richard Holloway Apr 6 '10 at 7:46
    
You also shouldn't have the spaces after the commas, many cron implementations will see them as separators. You may come across implementations that demand numeric months too, though I think this is rare these days. –  David Spillett Apr 6 '10 at 10:39
    
@David Spillett thanks we will get there in the end... Possibly my crapest answer ever. If I had any decency I would delete it;) –  Jon Rhoades Apr 6 '10 at 11:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.