1

I want to execute a script once an hour from 20:00 to 08:00. Would the following work?

0 20-8 * * * location_of_script_to_run

I'm currently using the following:

0 20,21,22,23,0,1,2,3,4,5,6,7,8 * * * location_of_script_to_run

Also, is there a way I can test this without having to actually wait? I imagine I'd need to temporarily alter the time on the system to trigger the execution.

Billiam
  • 11
  • 2
  • Try `0 20-8/1 * * * script` – Kinnectus Jun 26 '14 at 22:45
  • For testing the ["Temporarily change time"](http://unix.stackexchange.com/q/85336/1174) question from the Unix & Linux Stack Exchange might help you. – Cristian Ciupitu Jun 26 '14 at 23:17
  • I did view that link before posting this but it doesn't contain the answer I'm looking for. I'm specifically talking about a time range that involves 2 separate days. I suspect 20-8 will fail. I'll try it though. – Billiam Jun 26 '14 at 23:20
  • The 20-8 should do exactly the same as your "20,21,22...7,8" line. I'm guessing that cron knows to do a count from 20 and when it reaches 23 (11pm) it knows the next hour can only be 0... – Kinnectus Jun 27 '14 at 06:46

0 Answers0