User Tools

Site Tools


cronjobs

Format

Note: When creating crons, you will need to specify the FULL path to a command.
Eg. On the command-line you may type:

holland bk
This is because bash shells introduced the $PATH environment variable:
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
The shell will then search the environment variables from right to left until it finds the appropriate path. This allows you to type the command and options rather than the full path to the init script.
Cron DOES NOT have this functionality. You will need to type the full path:
# which holland
/usr/sbin/holland
The cron would then look like:
00 2 * * * /usr/sbin/holland -q bk


Format

To view the format of crontabs you can read the file /etc/crontab

minute   hour   day   month   dayofweek   command
  *        *     *      *       *
The diagram below shows a little more detail into the parameters of each column
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

Viewing configured crontabs

You can use the following command to see the configured cronjobs on the server:

crontab -e

Example Crontabs

min   hour   day   month   dayofweek   [command]
30    0      1    1,6,12     *    [0:30 Hrs  on 1st of Jan, June & Dec]
10    4      1      *        *     [1st of every month @ 4:10]

cronjobs.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1