2

If I add 5 jobs in my crontab, do they execute asynchronously in parallel ? Two of my jobs may take 10 minutes to complete and I want to know if I need to run them in the background (by adding the & at the end of the command).

4

crontab entries are processed independently, so yes, the jobs are run asynchronously, in parallel. You don't need to background them.

If you ever need to synchronise jobs, check out the techniques mentioned in Can a crontab job run concurrently with itself?.

1

The exact sequence in which jobs are executed will depend on the implementation of your systems' crond. What is your OS? If you have cronjob in a crontab:

Job 1
Job 2
Job 3

In Debian Job1 will start, without waiting to finish Job 2, etc.
In Debian and Ubuntu derivatives it is top-bottom
In FreeBSD it is bottom-top

If your cronjobs are in /etc/cron.hourly(or daily/monthly/weekly) - then the script that runs them does it sequently, not in paralel. (a script loops though them and waits for each to finish)

EDIT Add two different cronjobs (here I assume you have syslog configured)
* * * * * ls /etc/
* * * * * echo "whatever
tail -f /var/log/cron

  • We are using Centos 6 – Bon Ami May 18 '16 at 16:43
  • CentOs6 uses top-bottom as well. – Hristo Mohamed May 18 '16 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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