home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 40.12 Periodic Program Execution: The cron Facility Chapter 40
Delayed Execution
Next: 40.14 Including Standard Input Within a cron Entry
 

40.13 Adding crontab Entries

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

The -r option will remove all current crontab entries. Under SunOS, crontab has an additional -e option that lets you directly edit your current crontab entries in a single step (see article 40.15 for a script like that).

On BSD-based UNIX implementations, there is no separate crontab command, nor does each user get a personal crontab file. BSD 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 O'Reilly & Associates' Essential System Administration


Previous: 40.12 Periodic Program Execution: The cron Facility UNIX Power Tools Next: 40.14 Including Standard Input Within a cron Entry
40.12 Periodic Program Execution: The cron Facility Book Index 40.14 Including Standard Input Within a cron Entry

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System