5

How can I create a cron job that runs from 19:00 to 5:00? This doesn't work:

* 19-05 * * .... 

Should I use two jobs?

    * 19-23 * * .... 
    *  1-5  * * .... 
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
Farhadix
  • 1,395
  • 2
  • 12
  • 25

4 Answers4

9

On some distributions you can:

* 19-23,0-5 * * *

Check here: https://unix.stackexchange.com/questions/67158/crontab-entry-with-hour-range-going-over-midnight

Community
  • 1
  • 1
Paul Carlton
  • 2,785
  • 2
  • 24
  • 42
1

I can confirm that 19-23,0-5 works on Ubuntu server 16.04.

0

yes, you need to lines:

* 19-23 * * .... 
* 0-05 * * .... 
Nir Levy
  • 12,750
  • 3
  • 21
  • 38
0

Yes, you will end up to split it up, like this:

*/10 22-23 * * * logger "brooks was here"
*/10 00-05 * * * logger "brooks was here after midnight"
ferdy
  • 7,366
  • 3
  • 35
  • 46