Vladimir Todorov
Vladimir Todorov

Reputation: 79

Crontab - How to make script run every 15 minutes from 12:00 PM to 03:00 AM

I have tried so many things. For example, I first tried the most logic by me

*/15 12-3 * * * script.sh

but the crontab doesn't allow me to save it like that so I tried

*/15 12-0,0-3 * * * script.sh

and once again the crontab doesn't allow me to save it. Now I lose one hour because it is running like this

*/15 12-23,0-3 * * * script.sh

Can you please help me with this problem. I am sure there is a way I just cannot find it.

Upvotes: 0

Views: 1108

Answers (1)

SikZone
SikZone

Reputation: 248

*/15 0-3,12-23 * * * script.sh 

should do the trick. Note that ranges are inclusive, so the script will execute for all hours, without skipping any.

Upvotes: 1

Related Questions