Your Virtual Server crontab can be stored in any file you choose. For example, you may wish to create or upload a file called cronjobs in your Virtual Server home directory for your cron table. Each line in your crontab will either be an environment variable setting, a cron table entry, or a comment (beginning with the "#" character).
An environment setting is of the form,
NAME = VALUE
Several environment variables are set up automatically by the cron daemon. These include SHELL, LOGNAME, USER, and HOME. In addition to these settings, cron will look at a special environment variable, MAILTO. Any output generated by your cron jobs will be sent to the address specified by MAILTO (if it is not specified it will be sent to the owner of the crontab). If MAILTO is defined as an empty string (MAILTO=""), no mail will be sent.
Cron table entry fields
There are six fields in a crontab entry. The first five fields pertain to the time in which the event will be scheduled. The sixth field pertains to the actual command you wish to execute.
The format of the cron table entry includes five (5) time fields followed by a command. Commands are executed when the time specified by the date fields matches the server's current time. The five time fields are as follows:
Months, days, and weeks can be indicated as either names or numbers. When using names, use the first three letters (case-insensitive) of the particular month or day. Numbers must be used when indicating a range or list, however.
Installing a Crontab
After you have defined the cron table entries in your cronjobs file, you will need to register your crontab with the system. This can be done by running the command "crontab". For example, if you created your crontab file and named it "cronjobs" and stored it in your home directory, then Telnet or SSH to your Virtual Server and type the following command:
% crontab cronjobs
This will register your cron table file with the cron system daemon. If you ever need to review the current cron entries you have registered with the cron system daemon, you need simply type:
Some examples of complete cron entries are show below, implementing the vnukelog command as an example:
# Execute the "vnukelog" command at 1:15 (15 1) AM every day.
15 1 * * * /usr/local/bin/vnukelog
# Execute the "vnukelog" command at 11:40 PM (40 23) on the
# first day (1) of each month.
40 23 1 * * /usr/local/bin/vnukelog
# Execute the "vnukelog" command every 10 minutes for for the first
# half-hour (0-30/10) of the 9:00 AM and 5:00 PM hours (9,17) on
# Monday-Friday (1-5).
0-30/10 9,17 * * 1-5 /usr/local/bin/vnukelog
# Execute the "vnukelog" command at 4:00 AM, 8:00 AM,
#12:00 noon, 4:00 PM, and 8:00 PM (0 */4) on each
# Sunday (sun) every January (jan).
0 */4 * jan sun /usr/local/bin/vnukelog
# Execute the "vnukelog" command at 4:30 AM (30 4) on the first,
# fifteenth (1,15), and each Friday (fri) of every month.
30 4 1,15 * /usr/local/bin/vnukelog
# Execute the "vnukelog" command at 12:00 midnight (0 0) on
# August 19 (8) (aug).
0 0 19 8 * /usr/local/bin/vnukelog
0 0 19 aug * /usr/local/bin/vnukelog
#use /bin/sh to run commands, no matter what /etc/passwd says SHELL=/bin/shDocumentation
The following paragraphs explain the format of your crontab file and is adapted from the manual page on crontab (section 5). If you would like to review the man page, you may do so by connecting to your Virtual Server and typing:
% man crontab
% man 5 crontab