386 lines
14 KiB
HTML
386 lines
14 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>crontab</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="crontab"></a> <a name="tag_04_28"></a><!-- crontab -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_28_01"></a>NAME</h4>
|
|
|
|
<blockquote>crontab - schedule periodic background work</blockquote>
|
|
|
|
<h4><a name="tag_04_28_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> crontab</tt> <b>[</b><i>file</i><b>]</b><tt><br>
|
|
<br>
|
|
crontab</tt> <b>[</b> <tt>-e | -l | -r</tt> <b>]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_04_28_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>crontab</i> utility shall create, replace, or edit a user's crontab entry; a crontab entry is a list of commands and the
|
|
times at which they shall be executed. The new crontab entry can be input by specifying <i>file</i> or input from standard input if
|
|
no <i>file</i> operand is specified, or by using an editor, if <b>-e</b> is specified.</p>
|
|
|
|
<p>Upon execution of a command from a crontab entry, the implementation shall supply a default environment, defining at least the
|
|
following environment variables:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>HOME</i></dt>
|
|
|
|
<dd>A pathname of the user's home directory.</dd>
|
|
|
|
<dt><i>LOGNAME</i></dt>
|
|
|
|
<dd>The user's login name.</dd>
|
|
|
|
<dt><i>PATH</i></dt>
|
|
|
|
<dd>A string representing a search path guaranteed to find all of the standard utilities.</dd>
|
|
|
|
<dt><i>SHELL</i></dt>
|
|
|
|
<dd>A pathname of the command interpreter. When <i>crontab</i> is invoked as specified by this volume of
|
|
IEEE Std 1003.1-2001, the value shall be a pathname for <a href="../utilities/sh.html"><i>sh</i></a>.</dd>
|
|
</dl>
|
|
|
|
<p>The values of these variables when <i>crontab</i> is invoked as specified by this volume of IEEE Std 1003.1-2001 shall
|
|
not affect the default values provided when the scheduled command is run.</p>
|
|
|
|
<p>If standard output and standard error are not redirected by commands executed from the crontab entry, any generated output or
|
|
errors shall be mailed, via an implementation-defined method, to the user.</p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Users shall be permitted to use <i>crontab</i> if their names appear in the file <b>/usr/lib/cron/cron.allow</b>. If that file does
|
|
not exist, the file <b>/usr/lib/cron/cron.deny</b> shall be checked to determine whether the user shall be denied access to
|
|
<i>crontab</i>. If neither file exists, only a process with appropriate privileges shall be allowed to submit a job. If only
|
|
<b>cron.deny</b> exists and is empty, global usage shall be permitted. The <b>cron.allow</b> and <b>cron.deny</b> files shall
|
|
consist of one user name per line. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>crontab</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-e</b></dt>
|
|
|
|
<dd>Edit a copy of the invoking user's crontab entry, or create an empty entry to edit if the crontab entry does not exist. When
|
|
editing is complete, the entry shall be installed as the user's crontab entry.</dd>
|
|
|
|
<dt><b>-l</b></dt>
|
|
|
|
<dd>(The letter ell.) List the invoking user's crontab entry.</dd>
|
|
|
|
<dt><b>-r</b></dt>
|
|
|
|
<dd>Remove the invoking user's crontab entry.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>file</i></dt>
|
|
|
|
<dd>The pathname of a file that contains specifications, in the format defined in the INPUT FILES section, for crontab
|
|
entries.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>See the INPUT FILES section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>In the POSIX locale, the user or application shall ensure that a crontab entry is a text file consisting of lines of six fields
|
|
each. The fields shall be separated by <blank>s. The first five fields shall be integer patterns that specify the
|
|
following:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Minute [0,59]</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Hour [0,23]</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Day of the month [1,31]</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Month of the year [1,12]</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Day of the week ([0,6] with 0=Sunday)</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Each of these patterns can be either an asterisk (meaning all valid values), an element, or a list of elements separated by
|
|
commas. An element shall be either a number or two numbers separated by a hyphen (meaning an inclusive range). The specification of
|
|
days can be made by two fields (day of the month and day of the week). If month, day of month, and day of week are all asterisks,
|
|
every day shall be matched. If either the month or day of month is specified as an element or list, but the day of week is an
|
|
asterisk, the month and day of month fields shall specify the days that match. If both month and day of month are specified as an
|
|
asterisk, but day of week is an element or list, then only the specified days of the week match. Finally, if either the month or
|
|
day of month is specified as an element or list, and the day of week is also specified as an element or list, then any day matching
|
|
either the month and day of month, or the day of week, shall be matched.</p>
|
|
|
|
<p>The sixth field of a line in a crontab entry is a string that shall be executed by <a href="../utilities/sh.html"><i>sh</i></a>
|
|
at the specified times. A percent sign character in this field shall be translated to a <newline>. Any character preceded by
|
|
a backslash (including the <tt>'%'</tt> ) shall cause that character to be treated literally. Only the first line (up to a
|
|
<tt>'%'</tt> or end-of-line) of the command field shall be executed by the command interpreter. The other lines shall be made
|
|
available to the command as standard input.</p>
|
|
|
|
<p>Blank lines and those whose first non- <blank> is <tt>'#'</tt> shall be ignored.</p>
|
|
|
|
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The text files <b>/usr/lib/cron/cron.allow</b> and <b>/usr/lib/cron/cron.deny</b> shall contain zero or more user names, one per
|
|
line, of users who are, respectively, authorized or denied access to the service underlying the <i>crontab</i> utility. <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>crontab</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>EDITOR</i></dt>
|
|
|
|
<dd>Determine the editor to be invoked when the <b>-e</b> option is specified. The default editor shall be <a href=
|
|
"../utilities/vi.html"><i>vi</i></a>.</dd>
|
|
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>If the <b>-l</b> option is specified, the crontab entry shall be written to the standard output.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The user's crontab entry is not submitted, removed, edited, or listed.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_28_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The format of the crontab entry shown here is guaranteed only for the POSIX locale. Other cultures may be supported with
|
|
substantially different interfaces, although implementations are encouraged to provide comparable levels of functionality.</p>
|
|
|
|
<p>The default settings of the <i>HOME ,</i> <i>LOGNAME ,</i> <i>PATH ,</i> and <i>SHELL</i> variables that are given to the
|
|
scheduled job are not affected by the settings of those variables when <i>crontab</i> is run; as stated, they are defaults. The
|
|
text about "invoked as specified by this volume of IEEE Std 1003.1-2001" means that the implementation may provide
|
|
extensions that allow these variables to be affected at runtime, but that the user has to take explicit action in order to access
|
|
the extension, such as give a new option flag or modify the format of the crontab entry.</p>
|
|
|
|
<p>A typical user error is to type only <i>crontab</i>; this causes the system to wait for the new crontab entry on standard input.
|
|
If end-of-file is typed (generally <control>-D), the crontab entry is replaced by an empty file. In this case, the user
|
|
should type the interrupt character, which prevents the crontab entry from being replaced.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<ol>
|
|
<li>
|
|
<p>Clean up <b>core</b> files every weekday morning at 3:15 am:</p>
|
|
|
|
<pre>
|
|
<tt>15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs rm -f
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Mail a birthday greeting:</p>
|
|
|
|
<pre>
|
|
<tt>0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>As an example of specifying the two types of days:</p>
|
|
|
|
<pre>
|
|
<tt>0 0 1,15 * 1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>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 <tt>'*'</tt> ; for example:</p>
|
|
|
|
<pre>
|
|
<tt>0 0 * * 1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would run a command only on Mondays.</p>
|
|
</li>
|
|
</ol>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>All references to a <i>cron</i> daemon and to <i>cron</i> <i>files</i> have been omitted. Although historical implementations
|
|
have used this arrangement, there is no reason to limit future implementations.</p>
|
|
|
|
<p>This description of <i>crontab</i> is designed to support only users with normal privileges. The format of the input is based on
|
|
the System V <i>crontab</i>; however, there is no requirement here that the actual system database used by the <i>cron</i> daemon
|
|
(or a similar mechanism) use this format internally. For example, systems derived from BSD are likely to have an additional field
|
|
appended that indicates the user identity to be used when the job is submitted.</p>
|
|
|
|
<p>The <b>-e</b> option was adopted from the SVID as a user convenience, although it does not exist in all historical
|
|
implementations.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="at.html"><i>at</i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_28_22"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>This utility is marked as part of the User Portability Utilities option.</p>
|
|
|
|
<p>The normative text is reworded to avoid use of the term "must" for application requirements.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|