Cesar Cesar - 1 year ago 81
Linux Question

Set a cron in advanced time logic Linux

I know how to set up a cron which calls a script every 2 minutes. For example:

*/2 * * * *

But now I would like it to run only from 9.30 to 9.45, again every 2 minutes. What is the syntax for that purpose? I have tried with

*/2 9.30-9.45 * * *

but, obviously, it is not working.

Answer Source

In your particular case you can use:

30-45/2 9 * * * [command]

For more complex setups I think it's generally better to move the logic into a script that Cron would call every N minutes and that would check the time and exit immediately if the current time is not within the defined range.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download