fortypoundhead.com

CRON

Posted On 2007-04-27 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1542


daemon to execute scheduled commands

Syntax
cronHow to run the cron daemon: Cron should be started from /etc/rc or /etc/rc.local. It will return immediately, so you don''t need to start it with ''&''.

What cron does
Cron searches /var/spool/cron for crontab files which are named after accounts in /etc/passwd; crontabs found are loaded into memory. Cron also searches for /etc/crontab and the files in the /etc/cron.d/ directory, which are in a different format.

Cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute.

Modifying a cron job
To edit a users crontab entry, log into your system for that particular user and type crontab -e.
The default editor for the ''crontab -e'' command is vi.
Change the default editor by running: export VISUAL=''editor''

cron checks each minute to see if its spool directory''s modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modfied. Note that the crontab command updates the mod­time of the spool directory whenever it changes a crontab.

Mailing output
Cron will email to the user all output of the commands it runs, to silence this, redirect the output to a log file or to /dev/null
You can also redirect email to the user named in the MAILTO environment variable in the crontab, if such exists.

Cron comes from the word chronos, the Greek word for time.



About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.242.205.33

Before you can post, you need to prove you are human. If you log in, this test goes away.




Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers