diff --git a/en_US.ISO8859-1/books/handbook/config/chapter.sgml b/en_US.ISO8859-1/books/handbook/config/chapter.sgml index 5df507d93c..e038cf44c3 100644 --- a/en_US.ISO8859-1/books/handbook/config/chapter.sgml +++ b/en_US.ISO8859-1/books/handbook/config/chapter.sgml @@ -417,6 +417,100 @@ exit 0 system boot. + + + + + Tom + Rhodes + Contributed by + + + + + Configuring the <command>cron</command> utility + + Configuring the cron utility + + One of the most useful utilities in FreeBSD is &man.cron.8;. The + cron utility runs in the background and constantly + checks the /etc/crontab file. The cron + utility also checks the /var/cron/tabs directory, in + search of new crontab files. These + crontab files store information about specific + functions which cron is supposed to perform at + certain times. + + Let us take a look at the /etc/crontab file: + + + # /etc/crontab - root's crontab for FreeBSD +# +# $FreeBSD: src/etc/crontab,v 1.32 2002/11/22 16:13:39 tom Exp $ +# +SHELL=/bin/sh +PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin +HOME=/var/log +# +#minute hour mday month wday who command +# +*/5 * * * * root /usr/libexec/atrun +# +# Save some entropy so that /dev/random can re-seed on boot. +*/11 * * * * operator /usr/libexec/save-entropy +# +# Rotate log files every hour, if necessary. +0 * * * * root newsyslog +# +# Perform daily/weekly/monthly maintenance. +1 3 * * * root periodic daily +15 4 * * 6 root periodic weekly +30 5 1 * * root periodic monthly +# +# Adjust the time zone if the CMOS clock keeps local time, as opposed to +# UTC time. See adjkerntz(8) for details. +1,31 0-5 * * * root adjkerntz -a + + Like most of the configuration files in FreeBSD, the # + character represents a comment. Notice we have several lines here. Each + line has seven fields. The first five of these fields hold time information, + listed in minute, hour, day, month, and the day of the week. Some of these + fields have a * character, which represents every. + Thus, if we look at the periodic monthly listing, we can see that it is set to + run at minute thirty, hour five, on the first day of every month. Always + remember that time is in the twenty-four hour clock format. You can also see + that this command is set to be run as root. + + This is the basic set up for every crontab file, + although there is one thing different about this one. Field number six, where + we specified the username, only exists in the /etc/contrab + file. If you ever write your own crontab, which I know you + will if your reading this, use of this field should be avoided. + + The cron utility cannot read shell start up files, + therefor absolute paths need to be used in the + crontab. + + The final field here will define the action to be performed. This field can + be have any valid command, or shell script. So if you want a list of actions to + be performed, you can write a shell script to execute them. Then define this shell + script in your crontab. + + + Installing a <filename>crontab</filename> + + To install your freshly written crontab, just + use the crontab utility. The most common usage is: + + &prompt.root; crontab crontab + + There is also an option to list installed crontab files, + just pass the to crontab and look + over the output. + + + +