What is crond?
Crond daemon is used to execute cron jobs in the background.
5 crond Examples
1. Start cron daemon in the foreground
If crond doesn’t start by default on your system, and you like to run it only temporarily for testing, you can execute crond in the foreground using option -n
# crond -n
2. Allow any crontab set by users
Using option -p, cron daemon can allow any crontab that are set by the users
# crond -p
3. Send cronjob output to syslog
By default cron job sends the output using mail. If you like the cron job output to go to syslog, use the option -s. This is a good choice, when your system doesn’t have the ability to send email of the cron job output.
# crond -s
4. Use custom mail (or custom log) for sending cron output
By default cron job sends the output using sendmail. If you like to use a custom mail program (other than sendmail), or log the cron output using some custom shell script, you can specify those using the option -m.
In this case, the custom shell-script (or) custom-mail-program should accept the mail message from the standard input, and should parse the mail header to get the recipient mail address, and send it to them.
# crond -m [custom-shell-script | custom-mail-program]
5. Debug crond messaages
You can use one (or more) of the following debug flags to figure out what is happening when the crond is running.
- ext displays extended information
- sch displays about job scheduling related activities
- proc displays info about running processes
- pars displays how crond parses the crontab file
- load displays when the crontab database is getting loaded
- misc displays miscellaneous debug info
- test This is test only mode. i.e The cron jobs are not really executed, it just pretends as if it is executing the cron job.
You can combine one or more debug flags using comma delimiter while starting the cron daemon as shown below.
# crond -x proc,ext
Syntax and Options
/usr/sbin/crond [-n] [-p] [-s] [-i] [-m ] [-x [ext,sch,proc,pars,load,misc,test,bit]]
Explain the option of the crond command. e.g. of chmod shown below.
|Short Option||Long Option||Option Description|
|-s||Using this option you can instruct cron to redirect job output to syslog. Helpful when your system doesn’t have sendmail. You can also use this when the mail is turned off by -m off option.|
|-m||Using this option, you can use any shell command string to send the mail output of the cron jobs (i.e instead of using sendmail). The command should take the formatted mail message from standard input and send mail message to the using the recipeints from the headers.|
|-n||Using this option, you can run the cron deamon in the foreground. Use this if you are not starting crond during the startup (i.e from init), and you like to start crond temporarily.|
|-p||Using this option crond will permit any crontab that are defined by users.|
|-x||Using this option, you can set one or more of the debug flags for cron deamon.|