25.3. Adding crontab Entries
For a good tip on silencing cron job mailings, see Section 25.6.
Most recent versions of Unix have a special command for maintaining the crontab file. To create a new crontab file, create a file containing the desired crontab entries. Then run the crontab command to install the file in the cron spool area. For example, if user chavez executes the command below, the file mycron will be installed as /usr/spool/cron/crontabs/chavez:
$ crontab mycron
If chavez had previously installed crontab entries, they will be replaced by those in mycron; thus, any current entries that chavez wishes to keep must also be present in mycron.
The -l option to crontab lists the current crontab entries, and redirecting its output to a file will allow them to be captured and edited:
$ crontab -l >mycron $ vi mycron $ crontab mycron
On original BSD-based Unix implementations, there is no separate crontab command, nor does each user get a personal crontab file. It does distinguish between " global" crontab entries (in /usr/lib/crontab) and "local" entries (in /usr/lib/crontab.local) -- however, you have to edit these files directly, which will probably require you to become superuser. It's a good idea to collect personal and site-specific crontab entries in the crontab.local file.
-- AF, from Essential System Administration (O'Reilly, 2002)
Copyright © 2003 O'Reilly & Associates. All rights reserved.