Understanding cron files
There are separate cron directories set up to contain cron jobs that run hourly, daily, weekly, and monthly. These cron jobs are all set up to run from the /etc/crontab file. The default /etc/crontab file looks like this:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# run-parts
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# run-parts
|
01 |
* |
* |
* |
* |
root |
run- |
parts |
/etc/cron. |
.hourly |
|
02 |
4 |
* |
* |
* |
root |
run- |
parts |
/etc/cron. |
.daily |
|
22 |
4 |
* |
* |
0 |
root |
run- |
parts |
/etc/cron. |
.weekly |
|
42 |
4 |
1 |
* |
* |
root |
run- |
parts |
/etc/cron. |
.monthly |
The first four lines initialize the run-time environment for all subsequent jobs (the subshell in which jobs will run, the executable program search path, the recipient of output and error messages, and that user's home directory).
The next four lines execute (as the user root) the run-parts program that controls programs that you may wish to run periodically. run-parts is a shell script that takes a directory as a command-line argument. It then sequentially runs every program within that directory (shell scripts are most common, but binary executables and links are also evaluated). The default configuration executes programs in /etc/cron.hourly at one minute after every hour of every day; /etc/cron.daily at 4:02 a.m. every day; /etc/cron.weekly at 4:22 a.m. on Sundays; and /etc/cron.monthly at 4:42 a.m. on the first day of each month.
The following files are installed in cron directories by default:
/etc/cron.daily/logrotate.cron — Automates rotating, compressing, and manipulating system logfiles.
/etc/cron.daily/makewhatis.cron — Updates the whatis database (contains descriptions of man pages), which is used by the man -k, apropos, and whatis commands to find man pages related to a particular word.
/etc/cron.daily/slocate.cron — Updates the /var/lib/slocate/slocate.db database, which contains a searchable list of files on the machine (excluding temporary directories and network-mounted file systems).
/etc/cron.daily/tetex.cron — Removes TeX font files from /var/lib/texmf that haven't been accessed in 90 days.
/etc/cron.daily/tmpwatch — Removes files from /tmp, /var/tmp, and /var/catman that haven't been accessed in 10 days.
The makewhatis.cron script installed in /etc/cron.weekly is similar to the one in /etc/cron.daily, but it completely rebuilds the whatis database, rather than just updating the existing database.
In the /etc/cron.d directory, each individual file has the same format as the /etc/crontab file. The only file installed is /etc/cron.d/kmod, which executes the rmmod command every 10 minutes to remove from memory any unused kernel modules:
# rmmod -a is a two-hand sweep module cleaner */10 * * * * root /sbin/rmmod -as
Splitting up cron jobs in separate files in such a manner can be useful if different environment variables are necessary for each individual task.
Continue reading here: Getting cdrecord for writable CDs
Was this article helpful?