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

Lets say I create two cron jobs:

  • Cron Job A, runs every day at 8:00AM
  • Cron Job B, runs every day at 8:05AM

However, Cron Job A, takes 12 hours to run (don't ask why, this is an example).

Will Cron Job B get to run at 8:05AM or do cron jobs only get executed one at a time?

If a Cron Job that was previously running was interrupted by a System Restart/Reboot, will it resume/run again after subsequent boot?

share|improve this question
2  
The first part of this is so easy to test I'm surprised you didn't. –  Iain Sep 13 '13 at 7:26
    
Testing is one thing, but I'm trying to get information on the core of how cron works. Yes, I can probably browse through the cron source, but that would take longer. For instance, I'd like to know if each cron jobs are spawned off as a new process, which from my understanding it is. And also, whether there is a limit of simultaneously running cron jobs, which actually there also appears to be based on implementation. –  Adam B Sep 13 '13 at 15:27

3 Answers 3

Yes, cron job B will run at 8:05. You can also run more than one long-running job at 8:00 etc.

However, the job will not resume after a reboot. If you need something like that rewrite your job with a wrapper that gets scheduled often and that checks if it has something new to do or something else to continue. This will depend on the task you want to do, obviously.

share|improve this answer
    
If it came down to that, then I'd probably shift to a Daemon. I see that in terms of reboots/power outages, etc, Daemon's might be more robust. –  Adam B Sep 13 '13 at 15:30
    
@AdamB: There are many tasks that cron is unsuited for. As always, pick the tool appropriate for your task. E.g. it might be worthwile to look into anacron. –  Sven Sep 13 '13 at 16:16

They are run in parallel. Cron Job B will run at 8:05 am.

share|improve this answer

Each and Every cron on your system is isolated from each other, but the cron job execution time will solely depends upon the System Resources Allocation and the work for which Cron has been schedule.

share|improve this answer
    
Will it? I'd think it might also depend on what the cronjob is doing, on what input data or to what, and several other factors. –  Falcon Momot Sep 13 '13 at 7:29

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.