views:

259

answers:

2

I'm using perl cron, and I want to make a rule like this

run every xx min/hours starting at yy:yy time (until the end of time)

How would I put this into a cron string? perl:cron seems to use the same syntax as regular cron so a regular cron string should work

TIA!

+1  A: 

You can specify intervals with a slash. Here's every 5 minutes:

*/5 * * * *

This is every 2 hours:

0 */2 * * *

You cannot give a start/ end time in cron.

spoulson
NOTE: This only works if your interval is a factor of 60.
bukzor
+1  A: 

The short answer is that you will either need to write this yourself or find a different third-party package, due to your requirements. There's two things you're asking for that cron doesn't do:

  1. Run every X minutes.

    Say you want to run every 40 minutes, and you write this */40 * * * *. This actually runs every 60 minutes at 1:40, 2:40, etc.

  2. Start/Stop at time Y/Z.

    There's simply no cron syntax for this. You could use a couple more cronjobs to add/remove the main cronjob at the specified times, but this smells a lot like self-modifying code. Given the complexity (read: unreliability), it's probably better to find a different system.

bukzor
Thanks bukzor, I am now going to have to redo my scheduling subsystem, but better that I know about it now than my client find out in production.
Lerxst