Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ crontab(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

at(1)

atq(1)

atrm(1)

mail(1)

sh(1)

su(1)

vi(1)

cron(1M)

crontab(1)                                                       crontab(1)

NAME
     crontab - regularly execute commands at specific times

SYNOPSIS
     crontab [--] [file]                                           Format 1

     crontab -l [loginname]                                       Format 2

     crontab -r [loginname]                                       Format 3

     crontab -e [loginname]                                       Format 4

DESCRIPTION
     crontab is used to have commands, shell scripts or executable programs
     executed regularly at specific times.

     You can use crontab to:

     -  schedule command jobs (Format 1)

     -  have scheduled jobs listed (Format 2)

     -  delete scheduled jobs (Format 3)

     -  edit scheduled jobs (Format 4)

   Before the call

     If the file /etc/cron.d/cron.allow exists, you can only use crontab if
     your login name appears in it. If the file /etc/cron.d/cron.allow does
     not exist, you can only use crontab if your login name does not appear
     in the file /etc/cron.d/cron.deny. If neither /etc/cron.d/cron.allow
     nor /etc/cron.d/cron.deny exists, only the system administrator is
     allowed to use crontab.

     If only an empty deny file exists, for example, everyone is allowed to
     use crontab.

     Only the system administrator is allowed to create and modify the
     allow and deny files. Each line in these files contains precisely one
     login name.

     If a privileged user modifies another user's crontab file, resulting
     behavior may be unpredictable. Instead, the privileged user should
     first use su to switch to the other user's login name and thus obtain
     the permissions needed to make effective changes to that user's
     crontab file.

     Caution:
          If you inadvertently enter the crontab command with no arguments,
          do not attempt to get out with CTRL-D. This will cause all entries
          in your crontab file to be removed. Instead, use DEL to exit.



Page 1                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

OPTIONS
   Format 1: Scheduling command jobs

     crontab [--] [file]

     To schedule a command job with crontab you have to specify:

     -  the command (or shell script or program) that is to be executed,
        and

     -  the times at which it is to be executed (e.g. every Friday or every
        January 15).

     When you call crontab in the above format, crontab copies these speci-
     fications into your crontab file /var/spool/cron/crontabs/loginname.
     The /etc/cron process checks every minute whether there are commands
     in the crontab file which need to be executed, and if there are any,
     it has them executed.

     To execute the specified command, crontab invokes a new shell (sh)
     from your home directory. crontab supplies a default environment for
     every shell, defining HOME, LOGNAME, SHELL (/bin/sh), and PATH
     (:/bin:/usr/bin:/usr/lbin). If you wish to have your .profile exe-
     cuted, you must specify this explicitly in the crontab file.

     If neither the standard output nor the standard error output have been
     redirected for the commands in the crontab file, both the standard
     output and the standard error output will be sent to you by mail.

     There can be at most one crontab file per login name. If the crontab
     file /var/spool/cron/crontabs/loginname does not exist, it is created
     when crontab is called. If it already exists, its contents are
     overwritten. In other words, if you wish to schedule additional com-
     mand jobs with crontab, you should use the -e option.

     --   If file begins with a dash (-), the end of the command-line
          options must be marked with --.

     file Name of the file containing the commands and the times at which
          they are to be executed.

          file must be in the format described below (see STRUCTURE OF A
          crontab FILE).

          file not specified:

          crontab reads the text entered from the standard input. The text
          that you enter in this case must be in the format described below
          (see STRUCTURE OF A crontab FILE).





Page 2                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

   Format 2: Listing scheduled jobs

     crontab -l [loginname]

     -l   (list) crontab lists the contents of your crontab file
          /var/spool/cron/crontabs/loginname.

          If the file is not available, an error message is issued (see
          ERROR MESSAGES).

     loginname
          If a loginname is specified, the crontab file of the correspond-
          ing user is listed. However, only the system administrator is
          permitted to specify a loginname.

   Format 3: Deleting scheduled jobs

     crontab -r [loginname]

     -r   (remove) crontab deletes your crontab file
          /var/spool/cron/crontabs/loginname.

     loginname
          If a loginname is specified, the crontab file of the correspond-
          ing user is deleted. However, only the system administrator is
          permitted to specify a loginname.

   Format 4: Editing scheduled jobs

     crontab -e [loginname]

     -e   (edit) The -e option allows you to edit a copy of your crontab
          file or to create an empty file to edit (if crontab does not
          exist) and save this file as the current crontab file. The VISUAL
          environment variable determines which editor is called. If VISUAL
          is not defined, the EDITOR environment variable is checked, and
          if EDITOR is not defined, ed is invoked.

     loginname
          If a loginname is specified, the crontab file of the correspond-
          ing user is edited. However, only the system administrator is
          permitted to specify a loginname.












Page 3                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

STRUCTURE OF A crontab FILE

     Your crontab file, or the text that you enter from standard input,
     (see Format 1) must be in the following format:

     Text comprising:

     -  lines to define a command job, and

     -  comment lines, if required.

     Blank lines are not permitted.

     Command job definition lines

     A line defining a command job consists of six fields separated by
     blanks or tabs. The fields contain the following information:
     ______________________________________________________________________
    |   1     |   2   |       3       |     4   |       5      |     6    |
    |_________|_______|_______________|_________|______________|__________|
    | Minute  |  Hour |  Day of month |   Month |  Day of week |  Command |
    |_________|_______|_______________|_________|______________|__________|

     Fields 1 to 5 specify the times at which the command in field 6 is to
     be executed.

     Minute        Range of values: 0-59 or pattern

     Hour          Range of values: 0-23 or pattern

     Day of month  Range of values: 1-31 or pattern

     Month         Range of values: 1-12 or pattern

     Day of week   Range of values: 0-6 (0 = Sunday) or pattern

     Command       Name of the command that is to be executed at the speci-
                   fied time.

                   If your command needs to read data from standard input,
                   you have to use the percent character %. Each % charac-
                   ter in the command field that has not been escaped with
                   a backslash \ is interpreted as a newline character. The
                   shell executes the content of the command field only up
                   to the first unescaped percent or newline character; the
                   remainder of the field is passed to the command as stan-
                   dard input (see Example 1).







Page 4                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

     pattern may be:

     -  an asterisk * (standing for all legal values)

     -  a range described as number-number

     -  a comma-separated list of legal numbers or ranges, e.g.: 1,3,5 or
        1-3,5

     Specifying the day

     Two fields are available for specifying the day; field 3 (day of
     month) and field 5 (day of week).

     If you enter a number, a range or a list in the third field as well in
     the the fifth field, both specifications are valid, independently of
     each other.

     For example, if your crontab file contains the line:

     0 0 1,15 3 1 command

     then command will be executed on March 1 and March 15 as well as on
     every Monday in March.

     If you wish to specify the day in one field only, you must enter an
     asterisk in the second field. Thus if your crontab file contains the
     line:

     0 0 * 3 1 command

     then command will be executed on every Monday in March.

     Comment lines

     A comment line has the hash character # in column one and may be fol-
     lowed by any arbitrary text. You can use comment lines in the crontab
     file to explain the function of the command job or to arrange the job
     into sections for the sake of clarity. Please note that the input text
     that you pass to crontab can contain any number of comment lines but
     must not include any blank lines.













Page 5                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

ERROR MESSAGES

     crontab: you are not authorized to use cron. Sorry.

     See Before the call above.

     Format 1

     crontab: can't open your crontab file.

     You have called crontab with the name of a file which does not exist
     or cannot be accessed.

     crontab: error in previous line; ...

     If any line of the input text that you pass to crontab is not in the
     correct format, crontab displays the relevant line followed by the
     above error message. The ellipses (...) shown here are replaced by a
     more detailed description of the error, e.g.:

     unexpected character found in line

     An illegal character was found in the line.

     number out of bounds

     A specified number is not in the permitted range.

     Format 2

     crontab: can't open your crontab file.

     Your crontab file /var/spool/cron/crontabs/loginname does not exist
     and therefore cannot be read with crontab -l.

ENVIRONMENT VARIABLES
     VISUAL   The VISUAL environment variable determines which editor is
              used when the -e option is specified.

     EDITOR   If VISUAL is not set, the EDITOR environment variable deter-
              mines which editor is used when the -e option is specified.
              The default value is vi.

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed. If LCMESSAGES is undefined or is defined
     as the null string, it defaults to the value of LANG. If LANG is like-
     wise undefined or null, the system acts as if it were not internation-
     alized.





Page 6                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

     The LCALL environment variable governs the entire locale. LCALL
     takes precedence over all the other environment variables which affect
     internationalization.

EXAMPLES
     Example 1

     You want the system to remind you on May 15 every year that it is Aunt
     Jemima's birthday. To do this, you set up a file called birthday with
     the following contents:

     0 0 15 5 * echo Today is Aunt Jemima's birthday !!!

     Please note that since you only wish to make an entry for the day of
     the month and not for the day of the week, you must enter an asterisk
     in the "day of week" field.

     You now pass the file named birthday to your crontab file:

     $ crontab birthday

     The system will then send you the appropriate message via mail at
     00.00 hours on May 15 of each year. This will obviously only function
     if the system has not been turned off during that night.

     Example 2

     Let us assume that on every Monday, at 1:30 p.m., you want to remind
     yourself and a co-worker of your aerobics class that evening. Your
     reminder is to be displayed on the screen. You are at terminal tty007
     and she is at terminal tty014. You can also include comment lines in
     the input text so that your text is easier to read with crontab -l at
     a later stage. Your crontab file could then be set up as follows:

     # *   = all legal values
     # n-n = range
     # n,n = list
     # Day of week: 0 = Sunday
     #
     # Min  Hrs  Day(Mon)  Mon  Day(Wk)  Command
     #
     30   13      *        *    1      echo Aerobics this evening ! >/dev/tty007
     30   13      *        *    1      echo Aerobics this evening ! >/dev/tty014

     Every Monday at 1:30 p.m., you and your colleague will now receive the
     message "Aerobics this evening !" at your respective terminals (and
     not in your mailboxes).







Page 7                       Reliant UNIX 5.44                Printed 11/98

crontab(1)                                                       crontab(1)

     Example 3

     Every Monday, you want to mail the message below to user melody, who
     works on a system called jukebox:

     It may be blue
     But it will pass too!

     You do this by putting the following line in your crontab file:

     0 0 * * 1 mail melody@jukebox %It may be blue %But it will pass too!

FILES
     /etc/cron.d/cron.allow
          List of login names with permission to use crontab. One login
          name is entered per line.

     /etc/cron.d/cron.deny
          List of login names explicitly denied permission to use crontab.
          One login name is entered per line.

     /var/spool/cron/crontabs/loginname
          crontab file of the user identified by loginname.

SEE ALSO
     at(1), atq(1), atrm(1), mail(1), sh(1), su(1), vi(1), cron(1M).




























Page 8                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026