manpages.info - online man pages   

SunOS man pages : crontab (1)

User Commands                                          crontab(1)

NAME

crontab - user crontab file

SYNOPSIS

crontab [ filename ] crontab [ -elr ] username

DESCRIPTION

The crontab utility manages a user's access with cron (see cron(1M)) by copying, creating, listing, and removing cron- tab files. If invoked without options, crontab copies the specified file, or the standard input if no file is speci- fied, into a directory that holds all users' crontabs. crontab Access Control Users: Access to crontab is allowed: o if the user's name appears in /etc/cron.d/cron.allow. o if /etc/cron.d/cron.allow does not exist and the user's name is not in /etc/cron.d/cron.deny. Users: Access to crontab is denied: o if /etc/cron.d/cron.allow exists and the user's name is not in it. o if /etc/cron.d/cron.allow does not exist and user's name is in /etc/cron.d/cron.deny. o if neither file exists, only a user with the solaris.jobs.user authorization is allowed to submit a job. Note that the rules for allow and deny apply to root only if the allow/deny files exist. The allow/deny files consist of one user name per line. crontab Entry Format 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: minute (0-59), hour (0-23), day of the month (1-31), month of the year (1-12), day of the week (0-6 with 0=Sunday). SunOS 5.8 Last change: 13 Aug 1999 1 User Commands crontab(1) Each of these patterns may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign (meaning an inclusive range). Note that the specification of days may be made by two fields (day of the month and day of the week). Both are adhered to if specified as a list of elements. See EXAMPLES. The sixth field of a line in a crontab file is a string that is executed by the shell at the specified times. 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 com- mand field is executed by the shell. Other lines are made available to the command as standard input. Any line begin- ning with a `#' is a comment and will be ignored. The file should not contain blank lines. The shell is invoked from your $HOME directory with an arg0 of sh. Users who desire 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), TZ, and PATH. The default PATH for user cron jobs is /usr/bin; while root cron jobs default to /usr/sbin:/usr/bin. The default PATH can be set in /etc/default/cron; see cron(1M). If you do not redirect the standard output and standard error of your commands, any generated output or errors will be mailed to you.

OPTIONS

The following options are supported: -e Edits a copy of the current user's crontab file, or creates an empty file to edit if crontab does not exist. When editing is complete, the file is installed as the user's crontab file. If a username is given, the specified user's crontab file is edited, rather than the current user's crontab file; this may only be done by a user with the solaris.jobs.admin authoriza- tion. The environment variable EDITOR determines which editor is invoked with the -e option. The default edi- tor is ed(1). Note that all crontab jobs should be submitted using crontab; you should not add jobs by just editing the crontab file because cron will not be aware of changes made this way. -l Lists the crontab file for the invoking user. Only a user with the solaris.jobs.admin authorization can specify a username following the -r or -l options to SunOS 5.8 Last change: 13 Aug 1999 2 User Commands crontab(1) remove or list the crontab file of the specified user. -r Removes a user's crontab from the crontab directory.

EXAMPLES

Example 1: Cleaning up core files This example cleans up core files every weekday morning at 3:15 am: 15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs rm -f Example 2: Mailing a birthday greeting 0 12 14 2 * mailx john%Happy Birthday!%Time for lunch. Example 3: Specifying days of the month and week This example 0 0 1,15 * 1 would run 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 would run a command only on Mondays.

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of crontab: LC_TYPE, LC_MESSAGES, and NLSPATH. EDITOR Determine the editor to be invoked when the -e option is specified. The default editor is ed(1). If both the EDITOR and VISUAL environment variables are set, the value of the VISUAL variable is selected as the editor.

EXIT STATUS

The following exit values are returned: 0 Successful completion. >0 An error occurred.

FILES

/etc/cron.d main cron directory SunOS 5.8 Last change: 13 Aug 1999 3 User Commands crontab(1) /etc/cron.d/cron.allow list of allowed users /etc/default/cron contains cron default settings /etc/cron.d/cron.deny list of denied users /var/cron/log accounting information /var/spool/cron/crontabs spool area for crontab

ATTRIBUTES

See attributes(5) for descriptions of the following attri- butes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Availability | SUNWcsu | |_____________________________|_____________________________|

SEE ALSO

atq(1), atrm(1), auths(1), ed(1), sh(1), cron(1M), su(1M), auth_attr(4), attributes(5), environ(5)

NOTES

If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with <Control-d>. This removes all entries in your crontab file. Instead, exit with <Control-c>. If an authorized user modifies another user's crontab file, resulting behavior may be unpredictable. Instead, the super-user should first su(1M) to the other user's login before making any changes to the crontab file. When updating a user's crontab file with the crontab com- mand, the cron process sees this update immediately when no cron jobs are running. However, if cron is running any cron job(s) at the time of updating, it could take a maximum of 60 seconds before cron is aware of this update. Therefore, to be safe, a new job should be started at least 60 seconds after the current date and time. SunOS 5.8 Last change: 13 Aug 1999 4