Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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.

share|improve this answer
    
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 '11 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 '11 at 17:15

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.

share|improve this answer
    
What Joe said, for the second case. Good point, Joe! –  MadHatter Feb 8 '11 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.