Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't know where I can find more information about crontab, so I ask here. Crontab is it multithread? How does it work?

share|improve this question
Maybe your question is not so clear. Are you worried about the internals of the cron daemon, or about cron jobs to be executed in parallel? – Stéphane Gimenez Sep 8 '11 at 9:51
up vote 8 down vote accepted

Probably not. All cron has to do is (to express it simplified) watch until it is time to run one job or the other, and if so, fork a process which runs that job and periodically check if the job is finished in order to clean it up.

MT could be used for this waiting, but I think that would be overkill. With the wait()/waitpid() family functions, it is possible to have a look at all children at once (would be good for kindergarten teachers :-D). And you can have a look without blocking, so you have as well the possibility to continue looking for the time to execute the next job. And SIGCHLD exists as well.

share|improve this answer

There are a number of implementations of cron for Linux. Whether any of them are multi-threaded or not is not really a question that I think is relevant unless you're trying to write your own implementation of the cron daemon.

share|improve this answer
It could matter if you're expecting jobs run at the same time to run in sequence, and it would cause a problem if they ran simultaneously – Michael Mrozek Sep 8 '11 at 12:18
Jobs that are scheduled for the same time will not run in sequence, they will execute (close to) simultaneously. It does not matter if the cron daemon is implemented with a single or multiple threads. You can test this easily by adding three cron jobs to execute each minute; one sleep 40, one sleep 50 and one sleep 55. Then monitor the processes and you will see that all three run at the same time (at least for the first 40 seconds after each minute). – Kusalananda Sep 8 '11 at 12:59

Traditional unix commands of this sort are not multithreaded. They use a fork-exec model. In the case of cron, it forks off a shell to run the commands in the crontab line. The cron daemon does not wait for the child to finish executing, although IIRC it may handle certain signals sent by the child.

share|improve this answer

Your Answer


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.