spacer
  Home SunSolve Online Document
 

[ Printer Friendly Page ] [ Was this document useful? Yes or No ]
[ Notify if Document Changes ] [ Mark Document for Download ]
[ View/Edit Notifications ] [ View/Edit Marked Documents ]


Document ID   Title   Date
918   Administration and Usage of crontab [8/91]   31 Dec 1969
Top

01-AUG-1991

Administration and Usage of crontab
-------------- --- ----- -- -------

This article provides information on crontab administration and usage.

Options for crontab
------- --- -------

The crontab options are -e, -l, -r and null (no option).  (Refer to the man
pages for crontab(1).)

Option:

      crontab -e [ username ]            # edit crontab file
      crontab -l [ username ]            # list crontab file
      crontab -r [ username ]            # remove crontab file
      crontab    [ filename ]            # copy to crontab file

Where:

  -e        edit crontab file

  -l        list crontab file

  -r        remove crontab file

  null      copy to crontab file


General crontab Information
------- ------- -----------

The crontab file is used by cron to execute user commands at predesignated
times.

The crontab command is used to edit, list, or remove the crontab file for a
given user.  Only root can use the [username] parameter.

The crontab command, with no options or parameters, attempts to write standard
input to the crontab file. (See WARNING at the end of this section.)

The crontab file is formatted as follows:

  Minutes Hours Date Month Day-of-Week command

Where:

  Minutes        [0 to 59]

  Hours          [0 to 23]

  Date           [1 to 31]

  Month          [1 to 12]

  Day-of-Week    [0 to  7] (where 0 and 7=Sunday, 1=Monday, 2=Tuesday,
                 3=Wednesday, 4=Thursday, 5=Friday, and 6=Saturday).

  command        a script file or a bourne shell command

The following symbols can also be used in the above command syntax:

  *    can be used as a wildcard in any field except command.

  ,    can be used to separate values in a field.

  -    can be used to set ranges in a field.

For example:

  30 1 * 2,4,6,8,10,12 3-5 /usr/bin/wall /var/tmp/message

The above example sets the following:  At 1:30, Wednesday through Friday of
every other month, send a message to everyone on the system, using the wall
command.

WARNING:  If you inadvertently enter the crontab command with no argument, do
not attempt to exit by typing CTRL-D.  This removes all entries in your crontab
file.  Instead, exit by typing your interrupt character (normally CTRL-C).

crontab Problems and Solutions
------- -------- --- ---------

Below are crontab problems and solutions:

  Problem:            I edited the crontab file but the commands are still not
                      executed.

  Solution:           Be sure you are not editing the crontab file with a
                      simple text editor such as vi. Use the following command:

                        crontab -e

                      The above command invokes vi and then sends a signal to
                      cron that the changes have been made.

  Problem:            I deleted all the crontab entries using the following
                      command:

                        crontab -e

                      However, the following command shows that they are still
                      there:

                        crontab -l

  Solution:           The following command does not know what to do with empty
                      files, so it does not update any changes:

                        crontab -e

                      Use the following command to remove an entire crontab
                      file:

                        crontab -r

  Problem:            Cron jobs are sometimes executing twice on my pre-4.1
                      system.

  Solution:           A patch is available through your local Answer Center.
                      Please reference Patch ID number 100058-01 for bug number
                      1022379 when requesting this patch.


crontab Questions and Answers
------- --------- --- -------

Below are crontab questions and answers.

  Question:           Can we use an editor other than vi?

  Answer:             Yes, by setting the environment variable EDITOR or VISUAL
                      to editor (where editor represents the desired editor).
                      You must be super-user to set the environment variable.

                      The vi(1) editor is the default.  The environment
                      variable VISUAL or EDITOR indicates the alternate editor.

  Question:           Why do we receive email when our cron job dies?

  Answer:             There is no standard output to which cron is written.  To
                      avoid this, redirect the command output to a file or a
                      device, such as /dev/console or /dev/null.

  Question:           How can we check to ensure that our cron is running
                      correctly?

  Answer:             Add the following entry to your crontab file:

                        * * * * * date > /dev/console

                      It should print the date in the console every minute.
Document Content STB ID: 918

Top
 
 

 

SunSolve Online:  Edit Account Patches Submit a Service Order Diagnostic Tools Support Documents Y2K Central Security Information SunSolve Servers About SunSolve Contact Us Site Map /ETC Help
 
 
 
webtone webtone webtone webtone
 Copyright 1994-2000 Sun Microsystems, Inc.,  901 San Antonio Road, Palo Alto, CA 94303 USA.  All rights reserved.
 Terms of Use. Privacy Policy. Feedback
spacer