19

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?

2
  • 2
    The first part of this is so easy to test I'm surprised you didn't.
    – user9517
    Sep 13, 2013 at 7:26
  • 2
    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, 2013 at 15:27

3 Answers 3

15

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.

2
  • 1
    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, 2013 at 15:30
  • 3
    @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, 2013 at 16:16
7

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

3

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.

1
  • 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. Sep 13, 2013 at 7:29

You must log in to answer this question.

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