DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

crontab(1)


crontab -- user crontab file

Synopsis

crontab [file]

crontab -e [username]

crontab -r [username]

crontab -l [username]

Description

The crontab command copies the specified file, or standard input if no file is specified, into a directory that holds all users' crontab files.

The following options are available:


-e
Edits a copy of the user's crontab file, or creates an empty file to edit if one does not exist. If the editor exits with a non-zero status, the existing crontab file is left unchanged. When editing is complete, the file is installed as the user's crontab file. The crontab command determines which editor to invoke based on environment variables. When the POSIX2 environment variable is set, crontab invokes the editor specified by the EDITOR environment variable. If EDITOR is null (or not set), it invokes vi(1). When POSIX2 is not set, crontab invokes the editor specified by the VISUAL environment variable, and if that is null, it invokes the editor specified by the EDITOR environment variable, and if that is null, it invokes ed(1).

-l
Lists the user's crontab file.

-r
Removes the user's crontab from the crontab directory.

Only a privileged user can use username following the -e, -l, or -r options, to edit, list, or remove the crontab file of the specified user.

allow and deny files

Users can use crontab if their names appear in the file /etc/cron.d/cron.allow. If that file does not exist, the file /etc/cron.d/cron.deny is checked to determine if the user should be denied access to crontab. If neither file exists, only root can submit a job. If cron.allow does not exist and cron.deny exists but is empty, global usage is permitted. The allow and deny files consist of one user name per line.

crontab file

A crontab file consists of lines of six fields each. The fields are separated by spaces or tabs. The first five are integer patterns that specify the following: Each of these patterns may be either an asterisk (meaning all valid values) or a list of elements separated by commas. An element is either a number or two numbers separated by a dash (identifying an inclusive range). Note that the specification of days may be made by two fields (day of the month and day of the week). If both are specified as a list of elements, both are adhered to. For example, 0 0 1,15 * 1 runs a command on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to * (for example, 0 0 * * 1 runs a command only on Mondays).

The sixth field of a line in a crontab file is a string that is executed by the shell at the times specified. A percent character in this field (unless escaped by ``\'') is translated to a newline character. Only the first line (up to a ``%'' or end of line) of the command field is executed by the shell. The other lines are made available to the command as standard input.

Invocation environment

Any line beginning with a ``#'' is a comment and is ignored.

The shell specified in the /etc/passwd file for your login is used as long as its name ends in "/sh"; otherwise, /usr/bin/sh is used.

The shell is invoked from your HOME directory with an arg0 of sh. Users who want to have their .profile executed must explicitly do so in the crontab file. cron supplies a default environment for every shell, defining HOME, LOGNAME, SHELL(=/bin/sh), and PATH(=:/bin:/usr/bin:/usr/lbin).

Output

If you do not redirect the standard output and standard error of your commands, any generated output or errors is mailed to you.

Files


/etc/cron.d/cron.allow
list of allowed users

/etc/cron.d/cron.deny
list of denied users

/usr/sbin/cron.d
main cron directory

/var/spool/cron/crontabs
spool area

/var/cron/log
accounting information

/usr/lib/locale/locale/LC_MESSAGES/uxcore
language-specific message file (See LANG on environ(5).)

Notices

If you inadvertently enter the crontab command with no arguments, exit using the <Del> key. Do not exit with a <Ctrl>-d; if you do, then all entries in your crontab file will be removed.

If a privileged user modifies another user's crontab file, resulting behavior may be unpredictable. Instead, the privileged user should first su(1M) to the other user's login before making changes to the crontab file.

References

at(1), cron(1M), sh(1), su(1M)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004