Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In order to run cron in the night at 4 o'clock I need to write 4 * * * *?

And to run at 16.00 o'clock, it should be 16 * * * *?

thanks

share|improve this question

2 Answers 2

up vote 4 down vote accepted

No. This would run at the 4th and 16th minute of every hour.

You're looking for:

0 4,16 * * * command

That will run at both 4am and 4pm.

Or if the two commands are different:

0 4 * * * command
0 16 * * * another_command
  1. The first column sets the minutes. In these examples, I'm setting it at 0 so the event happens on the hour.

  2. The in the next column we set the hour you want it to run. We use absolute values but you can use */2 for "every other hour", etc.

  3. The next column says that we want this to happen every day of the month.

  4. The next column denotes the months that this should trigger on (all in this case).

  5. The last column says which days of the week this is allowed to trigger on. 0-7 (where both 0 and 7 are Sunday). * means it can trigger on any day of the week.

share|improve this answer
    
thanks, complete answer. I've also found this article that really helped me: thegeekstuff.com/2009/06/15-practical-crontab-examples –  Patrick Jan 7 '11 at 17:11

No, that's not correct. The meaning of the fields are:

* * * * *

  • minute (0 - 59)
  • hour (0 - 23)
  • day of month (1 - 31)
  • month (1 - 12)
  • day of week (0 - 6) (Sunday=0 or 7)

So for everyday 4am 4pm you should use:

* 4,16 * * *
share|improve this answer
3  
Not correct. This would run at every minute during 4am and 4pm. eg: 04:00, 04:01, 04:02, etc –  Oli Jan 7 '11 at 15:36

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.