CronJobs

  1. Edite um ficheiro (ex: cron.job) descrevendo os varios JOBS pretendidos. Em cada linha especifica-se os minutos, as horas, o dia do mes, o mes do ano, o dia da semana e por fim o path completo para o programa a exucutar. Tudo separado por espacos.
    Com excepcao do campo do programa, todos os outros tem o segunto formato: Exemplo de um ficeiro que descreve dois cronjobs. O primeiro corre entre as 9h e as 19h de meia em meia hora, nomeadamente aos 15m aos 45m de cada hora. O segundo corre no dia 1 de cada mes 'as 8h30m da manha.
    15,45 9-19 * * * /usr/users1/deec/jvv/test0
    30  8 1 * * /usr/users1/deec/jvv/test1
    
  2. Execute o comando crontab seguido do nome do ficheiro que descreve os Jobs'(ex: crontab cron.job)
  3. Para se certificar de quais os seus cronjobs execute
    crontab -l
  4. Para remover todos os seus cronjobs execute
    crontab -r
Segue-se a pagina do manual referente ao crontab



crontab(1)                                                         crontab(1)



NAME

  crontab - Submits a schedule of commands to cron

SYNOPSIS

  crontab [file]

  crontab -l | -v | -r | -e [ user name ]

STANDARDS

  Interfaces documented on this reference page conform to industry standards
  as follows:

  crontab:  XPG4, XPG4-UNIX

  Refer to the standards(5) reference page for more information about indus-
  try standards and associated tags.

FLAGS

  -e [username]
      Edits a copy of your crontab entry.  If the crontab entry does not
      exist, creates an empty entry to edit.  The -e flag invokes the editor
      specified by the EDITOR environment variable, or uses /usr/bin/vi by
      default.  The  crontab command installs the new entry when editing is
      complete.

      [Digital]  If username is specified, edits the file for the specified
      user.  You must have appropriate privileges to use this option.

  -l  Displays the contents of your crontab file.

  -r  Removes the crontab file from the crontab directory.

  -v  [Digital]  Displays the name of your crontab file and the date and time
      at which you submitted it with crontab.

PARAMETERS

  file     Path name of file that contains crontab specifications in the for-
           mat described.

DESCRIPTION

  The crontab command copies the specified file or standard input if you do
  not specify a file into the /var/spool/cron/crontabs directory, which holds
  all users' crontab files.

  The cron command runs commands according to the instructions in the crontab
  files.  The crontab files are named for users, and the commands in the
  files are run under the user's authority.  For example, the commands in the
  /var/spool/cron/crontabs/root file are run under root authority.  When you
  use the crontab command, the file under your authority is affected.  For
  example, if adm invokes the crontab -l command, the
  /var/spool/cron/crontabs/adm file is displayed.  If the username argument
  is included, the specified user's crontab file is listed and edited rather
  than the current user's crontab file.  You must have root privileges to
  specify the username argument.  By default, the vi editor is used.

  After cron runs commands according to the contents of your crontab file, it
  mails you the output from standard output and standard error for these com-
  mands, unless you redirect standard output or standard error.

                                   Note
       When entries are made to a crontab file by using the crontab
       command, all previous entries in the file are removed.

  You can use the crontab command if your user name appears in the
  /usr/lib/cron/cron.allow file.  If that file does not exist, the crontab
  command checks the /usr/lib/cron/cron.deny file to determine if you should
  be denied access to crontab.  The allow/deny files contain one user name
  per line.  If neither file exists, you can submit a job only if you are
  operating with superuser authority.

  Each crontab file entry consists of a line with six fields, separated by
  spaces and tabs.  The information in the fields specifies when the command
  runs and the name of the command.  The fields specify the following:

    +  The first field specifies the minute (0 to 59).

    +  The second field specifies the hour (0 to 23).

    +  The third field specifies the day of the month (1 to 31).

    +  The fourth field specifies the month of the year (1 to 12).

    +  The fifth field specifies the day of the week (0 to 6 for Sunday to
       Saturday).

    +  The sixth field specifies the shell command to be executed.

  You can specify the following values in the fields that indicate the time:

    +  An integer (within the appropriate range of values)

    +  Two integers separated by a dash to indicate an inclusive range

    +  A list of integers separated by commas

    +  An asterisk to select all possible values

  You can specify the days on which the command is to execute in two fields
  (day of the month and day of the week).  You can specify both fields, or
  you can specify only one field.  To use only one field to specify the days,
  the other field should contain an asterisk (*).  If both methods are used,
  the command is executed whenever either of the specifications is met.

  [Digital]  For example, the following entry runs command at midnight on the
  first and fifteenth days of each month, as well as every Monday:

       0 0 1,15 * 1 command

  The cron program runs the command named in the sixth field at the specified
  date and time.  If you include a percent sign (%) in the sixth field, cron
  treats everything that precedes it (in that field) as the command invoca-
  tion, and makes all that follows it available to standard input, unless you
  escape the percent sign (\%) or double quote it ("%").  An exclamation
  point (!) in the sixth field is translated as a newline character.

  The shell runs only the first line of the command field (up to a percent
  sign or End-of-Line).  All other lines are made available to the command as
  standard input.

  The cron program invokes a subshell from your $HOME directory.  This means
  that it will not run your .profile file.  If you schedule a command to run
  when you are not logged in and you want to have commands in your .profile
  run, you must explicitly do so in the crontab file.  (For a more detailed
  discussion of how sh can be invoked, see the sh command.)

  The cron program supplies a default environment for every shell, defining
  HOME, LOGNAME, SHELL (=/usr/bin/sh), and PATH (=:/usr/bin).

  [Digital]  To submit commands to the cron daemon, invoke the crontab com-
  mand with the -e flag, or perform the following tasks:

   1.  [Digital]  Become the user that corresponds to the appropriate file in
       the /usr/spool/cron/crontabs directory.  For example, if you want to
       submit commands that will run under adm authority, become user adm.

   2.  [Digital]  Use the crontab command with the -l flag to copy the
       appropriate file from the /usr/spool/cron/crontabs directory to a tem-
       porary file in your home directory.  For example, if you are user adm,
       you could use the following command:
            crontab -l > temp_adm

   3.  [Digital]  Edit the temporary file and add the commands you want to
       run at a specified time.

   4.  [Digital]  Use the crontab command and specify the temporary file to
       submit the commands to the cron daemon.

NOTES

   1.  When entries are made to a crontab file, all previous entries are
       erased.

   2.  If your user ID is associated with more than one user name, crontab
       uses the first user name that appears in the /etc/passwd file, regard-
       less of which user name you might actually be using.

   3.  [Digital]  The file /usr/lib/cron is a symbolic link to /var/adm/cron.

   4.  [Digital]  If cron.allow exists, the superuser's user name must appear
       there for that superuser to be able to use the command.

ENVIRONMENT VARIABLES

  The following environment variables affect the execution of crontab:

  EDITOR   Determines the editor used with the -e flag.

  LANG     Provides a default value for the internationalization variables
           that are unset or null. If LANG is unset or null, the correspond-
           ing value from the default locale is used. If any of the interna-
           tionalization variables contain an invalid setting, the utility
           behaves as if none of the variables had been defined.

  LC_ALL   If set to a non-empty string value, overrides the values of all
           the other internationalization variables.

  LC_CTYPE Determines the locale for the interpretation of sequences of bytes
           of text data as characters (for example, single-byte as opposed to
           multibyte characters in arguments).

  LC_MESSAGES
           Determines the locale for the format and contents of diagnostic
           messages written to standard error.

  NLSPATH  Determines the location of message catalogues for the processing
           of LC_MESSAGES.

EXAMPLES

  The following example writes the time to the console every hour on the
  hour:

       0 * * * * echo The hour is `date`. >/dev/console


  The following example runs calendar at 6:30 a.m. every Monday, Wednesday,
  and Friday:

       30 6 * * 1,3,5 /usr/bin/calendar -

  The following example writes the contents of happyholidays.txt to all users
  logged in at 4:00 p.m. each Friday in December and each day between
  December 10 and December 31 inclusive:

       0 16 10-31 12 5 /usr/sbin/wall /var/tmp/happyholidays.txt


FILES

  /var/spool/cron/crontabs
            Directory containing the crontab files.

  /var/adm/cron/cron.allow
            List of allowed users.

  /var/adm/cron/cron.deny
            List of denied users.

  /var/adm/cron/log
            Log of cron activity.

  /etc/passwd
            Contains user information.

  $HOME/.profile
            User profile.

EXIT VALUES

  The following exit values are returned:

  0   Successful completion

  >0  An error occurred

RELATED INFORMATION

  Commands:  at(1), cron(8), mail(1), mailx(1), Bourne shell sh(1b),
  POSIX shell sh(1p)

  Standards:  standards(5)


Isidro Vila Verde
Serprest