Next: , Previous: , Up: Top   [Contents][Index]


4 The crontab Utility

The crontab utility allows the user to list, edit or remove personal or group crontabs.

The micrond cron daemon reads crontabs from several crontab groups, two of which contain crontabs for particular system users. The user crongroup contains per-user crontabs, and the group crongroup contains user crontabs editable by a group of users (see Crongroups).

By default, crontab operates on per-user crontabs. To edit group crontabs, the -g option must be specified.

When run without arguments, crontab enters copy mode, in which it copies the content of the supplied file to the user personal crontab, overwriting its prior content. For example

crontab newfile

overwrites the current crontab schedule of the user with the content of the file newfile.

To list the content of the crontab, use the -l option. It will be displayed on standard output.

To edit it, run crontab -e. A temporary copy of the crontab will be created and loaded to the editor specified by the VISUAL environment variable. If it is unset, the EDITOR variable is consulted. If this variable is unset as well, the built-in default ‘vi’ will be used.

Once you quit the editor, the edited crontab will be atomically moved to your personal crontab and re-read by micrond.

The -r option removes the crontab. Use it with caution. No backup copies are preserved.

When using destructive operations (such as copying or removal), it is safer to use the -i option which instructs the program to ask for the user consent before undertaking the modification.

The super-user can address the crontab of a particular user by supplying the user login name with the -u option. The use of this option is restricted for super-user, except if used together with the -g option.

User crontab groups contain multiple files for each system user. They are useful for certain pseudo-accounts. For example, a site running multiple web services may need to install separate crontabs for each of them and to allow users who run these services to edit their crontabs. This is done using the -g option. The name of the account for which the crontab is edited is supplied with the -u option. For example, to edit a crontab ‘portal’ in account ‘www-data’, one would use:

crontab -g -u www-data -e portal

The use of group crontabs for account x is allowed only for users who are members of the primary group of x.


Next: , Previous: , Up: Top   [Contents][Index]