Friday, January 21, 2011

Fractional hours in cron job under CentOS 5?

Ok, so I have a cron job that runs in every minute between 10:00 and 17:00 every day, every month from Monday to Friday.

My problem is that currently it runs from 10:00 - 17:00 (cron entry in hour column 10-16) and I want it to run from 10:00 to 16:25

I tried to put this in the hour column 10-16:25 but it doesn't work...

Can I set fractional hour ranges? If yes, how?

Thanks.

  • Can you split it in two lines? Something like:

    0-59 10-15 x x x x
    0-25 16 x x x x
    
    feketegy : @chmee I think this is a good solution, though it's not possible to create it with one line?
    chmeee : I don't know if you could do that with cron but... have you looked if you could achieve this goal with upstart?
    chmeee : Oops, I confused upstart with launchd. Cron functionality will be added later: http://upstart.ubuntu.com/faq.html#replace-cron
    From chmeee
  • If you don't want to split the cron job as chmee suggests you could get the functionality you desire by using a scripted solution. The script, which is run from the cron job, can test the time range and run the appropriate command(s) only if the range is correct. It's a little more work but provides vastly more flexibility.

    feketegy : @John Gardeniers: Yes this is how works currently. My only problem is that the script is still running after 16:25 and checking the time which imho is a waste of resources
    John Gardeniers : A script that when started checks the time and exists if that time is outside its operational window would run so briefly and use so little of your resources that I really think it can be ignored from the waste point of view.

0 comments:

Post a Comment