5

I want to run three cron jobs commands twice per hour (once every half hour) and the interval between these command should be 1-2 minutes. How should I configure cron jobs from cpanel?

2 Answers 2

14

I can't speak for cpanel, I'm afraid, but the crontab entries (if you can get to those) should look like this:

1,31 * * * *  /path/job1
3,33 * * * *  /path/job2
5,35 * * * *  /path/job3

That'll run each twice an hour, at 1, 3, and 5 minutes past the hour and half-hour.

2
  • Will the interval change from 2 to 3 minutes in this case: 1,31 * * * * /path/job1 4,33 * * * * /path/job2 7,35 * * * * /path/job3
    – Levani
    Feb 8, 2011 at 16:47
  • 1
    It'll change to three minutes for the ones that run after the hour, but not the ones that run after the half-hour. Try 1,31 / 4,34 / 7,37 for both. It's just the number of minutes past the hour that each job should run, with each job running at two different times past each hour - do you see the logic?
    – MadHatter
    Feb 8, 2011 at 17:15
3

The interval between starting the jobs should be 2 minutes, or the interval from after one finishes 'til the next one starts should be 2 minutes?

If it's the first case, see MadHatter's comment.

If it's the second case, it's easiest to wrap the whole thing in a shell script, and do sleep 120 in between.

I'll often do this if the next task shouldn't fire off if the previous task didn't return cleanly. It also makes it easier to set a semaphore for the whole group of tasks so if a task gets hung, the next time it runs, you don't kick off the tasks again.

1
  • What Joe said, for the second case. Good point, Joe!
    – MadHatter
    Feb 8, 2011 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .