2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
4 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
7 .\" are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
8 .\" and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\" This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH CRONTAB 1 "Oct 25, 2017"
15 crontab \- user crontab file
19 \fB/usr/bin/crontab\fR [\fIfilename\fR]
24 \fB/usr/bin/crontab\fR \fB-e\fR [\fIusername\fR]
29 \fB/usr/bin/crontab\fR \fB-l\fR [\fIusername\fR]
34 \fB/usr/bin/crontab\fR \fB-r\fR [\fIusername\fR]
39 The \fBcrontab\fR utility manages a user's access with \fBcron\fR (see
40 \fBcron\fR(1M)) by copying, creating, listing, and removing \fBcrontab\fR
41 files. If invoked without options, \fBcrontab\fR copies the specified file, or
42 the standard input if no file is specified, into a directory that holds all
46 If \fBcrontab\fR is invoked with \fIfilename\fR, this overwrites an existing
47 \fBcrontab\fR entry for the user that invokes it.
48 .SS "\fBcrontab\fR Access Control"
50 Users: Access to \fBcrontab\fR is allowed:
55 if the user's name appears in \fB/etc/cron.d/cron.allow\fR.
61 if \fB/etc/cron.d/cron.allow\fR does not exist and the user's name is not in
62 \fB/etc/cron.d/cron.deny\fR.
66 Users: Access to \fBcrontab\fR is denied:
71 if \fB/etc/cron.d/cron.allow\fR exists and the user's name is not in it.
77 if \fB/etc/cron.d/cron.allow\fR does not exist and user's name is in
78 \fB/etc/cron.d/cron.deny\fR.
84 if neither file exists, only a user with the \fBsolaris.jobs.user\fR
85 authorization is allowed to submit a job.
91 if Auditing is enabled, the user's shell is not audited and the user is
92 not the \fBcrontab\fR owner. This can occur if the user logs in by way of a
93 program, such as some versions of \fBSSH\fR, which does not set audit
98 The rules for \fBallow\fR and \fBdeny\fR apply to \fBroot\fR only if the
99 \fBallow\fR/\fBdeny\fR files exist.
102 The \fBallow\fR/\fBdeny\fR files consist of one user name per line.
103 .SS "\fBcrontab\fR Entry Format"
105 A \fBcrontab\fR file consists of lines of six fields each. The fields are
106 separated by spaces or tabs. The first five are integer patterns that specify
113 day of the month (1\(mi31),
114 month of the year (1\(mi12),
115 day of the week (0\(mi6 with 0=Sunday).
122 Each of these patterns can be either an asterisk (meaning all legal values) or
123 a list of elements separated by commas. An element is either a number or two
124 numbers separated by a minus sign (meaning an inclusive range). Time specified
125 here is interpreted in the currently active timezone. At the top of the crontab
126 file this is the timezone which is set system-wide in /etc/default/init. A user
127 can add a line such as:
138 \&...and all subsequent entries will be interpreted using that timezone, until
139 a new \fBTZ=\fR\fItimezone\fR line is encountered. The specification of days
140 can be made by two fields (day of the month and day of the week). Both are
141 adhered to if specified as a list of elements. See \fBEXAMPLES\fR.
144 The sixth field of a line in a \fBcrontab\fR file is a string that is executed
145 by the shell at the specified times. A percent character in this field (unless
146 escaped by \fB\e\fR\|) is translated to a \fINEWLINE\fR character.
149 Only the first line (up to a \fB`\|%\|'\fR or end of line) of the command field
150 is executed by the shell. Other lines are made available to the command as
151 standard input. Any blank line or line beginning with a \fB`\|#\|'\fR is a
152 comment and is ignored.
155 The shell is invoked from your $HOME directory. As with $TZ, both $SHELL and
156 $HOME can be set by having a line such as:
160 SHELL=/usr/bin/\fIsomeshell\fR
171 HOME=\fIsomedirectory\fR
178 \&...which will take precedence for all the remaining entries in the
179 \fBcrontab\fR or until there is another \fBHOME\fR or \fBSHELL\fR entry. It is
180 invoked with an \fBarg0\fR of the basename of the $SHELL that is currently in
181 effect. A user who wants to have his \fB\&.profile\fR or equivalent file
182 executed must explicitly do so in the \fBcrontab\fR file. \fBcron\fR supplies
183 a default environment for every shell, defining HOME, LOGNAME, SHELL, TZ, and
184 PATH. The default PATH for user \fBcron\fR jobs is \fB/usr/bin\fR; while root
185 \fBcron\fR jobs default to \fB/usr/sbin:/usr/bin\fR. The default PATH can be
186 set in \fB/etc/default/cron\fR (see \fBcron\fR(1M)). The TZ, HOME, and SHELL
187 environment variables are set to match those that are in effect in the
188 \fBcrontab\fR file at the time.
191 If you do not redirect the standard output and standard error of your commands,
192 any generated output or errors are mailed to you.
193 .SS "\fBcrontab\fR Environment Variables"
195 The following variables are supported:
203 Allows the user to choose and alternative directory for cron to change
204 directory to prior to running the command. For example:
222 The name of the shell to use to run subsequent commands. For example:
240 Allows the user to choose the timezone in which the \fBcron\fR entries are run.
241 This effects both the environment of the command that is run and the timing of
242 the entry. For example, to have your entries run using the timezone for
256 Each of these variables affects all of the lines that follow it in the
257 \fBcrontab\fR file, until it is reset by a subsequent line resetting that
258 variable. Hence, it is possible to have multiple timezones supported within a
259 single \fBcrontab\fR file.
262 The lines that are not setting these environment variables are the same as
263 crontab entries that conform to the UNIX standard and are described elsewhere
265 .SS "Setting \fBcron\fR Jobs Across Timezones"
267 The default timezone of the \fBcron\fR daemon sets the system-wide timezone for
268 \fBcron\fR entries. This, in turn, is by set by default system-wide using
269 \fB/etc/default/init\fR.
272 If some form of \fBdaylight savings\fR or \fBsummer/winter time\fR is in
273 effect, then jobs scheduled during the switchover period could be executed
274 once, twice, or not at all.
277 The following options are supported:
284 Edits a copy of the current user's \fBcrontab\fR file, or creates an empty file
285 to edit if \fBcrontab\fR does not exist. When editing is complete, the file is
286 installed as the user's \fBcrontab\fR file.
288 The environment variable \fBEDITOR\fR determines which editor is invoked with
289 the \fB-e\fR option. All \fBcrontab\fR jobs should be submitted using
290 \fBcrontab\fR. Do not add jobs by just editing the \fBcrontab\fR file, because
291 \fBcron\fR is not aware of changes made this way.
293 If all lines in the \fBcrontab\fR file are deleted, the old \fBcrontab\fR file
294 is restored. The correct way to delete all lines is to remove the \fBcrontab\fR
295 file using the \fB-r\fR option.
297 If \fIusername\fR is specified, the specified user's \fBcrontab\fR file is
298 edited, rather than the current user's \fBcrontab\fR file. This can only be
299 done by root or by a user with the \fBsolaris.jobs.admin\fR authorization.
308 Lists the \fBcrontab\fR file for the invoking user. Only root or a user with
309 the \fBsolaris.jobs.admin\fR authorization can specify a username following the
310 \fB-l\fR option to list the \fBcrontab\fR file of the specified user.
319 Removes a user's \fBcrontab\fR from the \fBcrontab\fR directory. Only root or a
320 user with the \fBsolaris.jobs.admin\fR authorization can specify a username
321 following the \fB-r\fR option to remove the \fBcrontab\fR file of the specified
327 \fBExample 1 \fRCleaning up Core Files
330 This example cleans up \fBcore\fR files every weekday morning at 3:15 am:
335 \fB15 3 * * 1-5 find $HOME\fR \fB-name\fR\fBcore 2>/dev/null | xargs rm\fR \fB-f\fR
341 \fBExample 2 \fRMailing a Birthday Greeting
344 This example mails a birthday greeting:
349 \fB0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.\fR
355 \fBExample 3 \fRSpecifying Days of the Month and Week
358 This example runs a command on the first and fifteenth of each month, as well
371 To specify days by only one field, the other field should be set to *. For
384 would run a command only on Mondays.
387 \fBExample 4 \fRUsing Environment Variables
390 The following entries take advantage of \fBcrontab\fR support for certain
391 environment variables.
397 HOME=/local/home/user
399 0 0 * * * echo $(date) > midnight.GMT
401 0 0 * * * echo $(date) > midnight.PST
403 HOME=/local/home/myuser
411 The preceding entries allow two jobs to run. The first one would run at
412 midnight in the GMT timezone and the second would run at midnight in the PST
413 timezone. Both would be run in the directory \fB/local/home/user\fR using the
414 Korn shell. The file concludes with \fBTZ\fR, \fBHOME\fR, and \fBSHELL\fR
415 entries that return those variable to their default values.
417 .SH ENVIRONMENT VARIABLES
419 See \fBenviron\fR(5) for descriptions of the following environment variables
420 that affect the execution of \fBcrontab\fR: \fBLANG\fR, \fBLC_ALL\fR,
421 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
428 The \fBPATH\fR in \fBcrontab\fR's environment specifies the search path used to
438 Determine the visual editor to be invoked when the \fB-e\fR option is
439 specified. If \fBVISUAL\fR is not specified, then the environment variable
440 \fBEDITOR\fR is used. If that is not set, the default is \fBvi\fR(1).
448 Determine the editor to be invoked when the \fB-e\fR option is specified. The
449 default editor is \fB/usr/bin/vi\fR.
454 The following exit values are returned:
461 Successful completion.
476 \fB\fB/etc/cron.d\fR\fR
485 \fB\fB/etc/cron.d/cron.allow\fR\fR
488 list of allowed users
494 \fB\fB/etc/default/cron\fR\fR
497 contains cron default settings
503 \fB\fB/etc/cron.d/cron.deny\fR\fR
512 \fB\fB/var/cron/log\fR\fR
515 accounting information
521 \fB\fB/var/spool/cron/crontabs\fR\fR
524 spool area for \fBcrontab\fR
529 See \fBattributes\fR(5) for descriptions of the following attributes:
530 .SS "\fB/usr/bin/crontab\fR"
536 ATTRIBUTE TYPE ATTRIBUTE VALUE
538 Interface Stability Standard
543 \fBatq\fR(1), \fBatrm\fR(1), \fBauths\fR(1), \fBed\fR(1), \fBsh\fR(1),
544 \fBvi\fR(1), \fBcron\fR(1M), \fBsu\fR(1M), \fBauth_attr\fR(4),
545 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
548 If you inadvertently enter the \fBcrontab\fR command with no arguments, do not
549 attempt to get out with Control-d. This removes all entries in your
550 \fBcrontab\fR file. Instead, exit with Control-c.
553 When updating \fBcron\fR, check first for existing \fBcrontab\fR entries that
554 can be scheduled close to the time of the update. Such entries can be lost if
555 the update process completes after the scheduled event. This can happen
556 because, when \fBcron\fR is notified by \fBcrontab\fR to update the internal
557 view of a user's \fBcrontab\fR file, it first removes the user's existing
558 internal \fBcrontab\fR and any internal scheduled events. Then it reads the new
559 \fBcrontab\fR file and rebuilds the internal \fBcrontab\fR and events. This
560 last step takes time, especially with a large \fBcrontab\fR file, and can
561 complete \fBafter\fR an existing \fBcrontab\fR entry is scheduled to run if it
562 is scheduled too close to the update. To be safe, start a new job at least 60
563 seconds after the current date and time.
566 If an authorized user other than root modifies another user's \fBcrontab\fR
567 file, the resulting behavior can be unpredictable. Instead, the authorized user
568 should first use \fBsu\fR(1M) to become superuser to the other user's login
569 before making any changes to the \fBcrontab\fR file.
572 Care should be taken when adding \fBTZ\fR, \fBSHELL\fR and \fBHOME\fR variables
573 to the \fBcrontab\fR file when the \fBcrontab\fR file could be shared with
574 applications that do not expect those variables to be changed from the default.
575 Resetting the values to their defaults at the bottom of the file will minimize
576 the risk of problems.