Home > other >  How to run a Cron job for every 5 mins for only 30 mins?
How to run a Cron job for every 5 mins for only 30 mins?

Time:12-07

I want to run a Cron job for every 5 mins for 30 mins, starting at 22:30 till 23:00.

To do this I wrote it like this

0 30,0/5 22 ? * * *

If you put this in https://crontab.cronhub.io/

It will say:

At 30 minutes past the hour and every 5 minutes, starting every hour, between 10:00 PM and 10:59 PM

But when I looked at the logs, I see it started the run at 22:00 till 22:55.

Why is this happening? Also, how can I make it work like the way I want it to.

CodePudding user response:

To run a Cron job every 5 minutes for 30 minutes, starting at 22:30 till 23:00, you can use the following syntax:

30-59/5 22 * * *
  • Related