Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having trouble finding an answer to this question thorough google:

How exatly does CRON in ubuntu execute jobs?

Does it spawn each new job in its own process?

Say i have two cron jobs:

@reboot /some/really/slow/job
* * * * * /some/quick/job

Will these jobs run side by side, or will the first one block the second until its done?

Secondly, does Cron affect redirects? Say i have a script which contains something like

rsync --verbose /from /to &>>rsynclog.log

Will the log file be written when called from CRON? Or does it end up somewhere else?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

This answer is for ubuntu. Other linux / unix operating systems may vary slighty.

Every minute the cron daemon reads all the crontab files and loads them into memory. For each cron entry which is to be run (determined by the crontab time fields) cron forks a copy of itself.

The forked cron child process then executes a new shell (typically /bin/sh but this can be overridden) to execute the crontab command. cron itself only forks the child processes that manage the jobs. So the cron entries are run concurrently - if one job takes an hour for example, it will not impact on the execution of any other cron jobs.

Redirection should work as normal and the output file will be written to the $HOME directory of the user who owns the crontab. It some cases it is worth providing the full path to commands and redirected files to avoid issues with PATH and HOME settings.

share|improve this answer
add comment

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.