![]() |
The iServer Virtual Server System includes access to a daemon¹ which can execute scheduled commands. This daemon, commonly known as "cron", reads a file of dates and commands that you build called a cron table or "crontab" for short. With your individual crontab, you can in effect tell the system to `run this command at this time on this date'.
Your individual crontab can be stored in any file you choose. For
example, you may wish to create a file "cronjobs" in your home directory
for your cron table. 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 " Each line in your crontab will either be an environment setting or a cron table entry. Lines that begin with "#" are considered comments and are ignored. An environment setting is of the form,
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 by empty (MAILTO=""), no mail will be sent. 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 current time. The five time fields are as follows:
A field may be an asterisk (*), which indicates all values in the range are acceptable. Ranges of numbers are allowed, i.e. "2-5" or "8-11", and lists of numbers are allowed, i.e. "1,3,5" or "1,3,8-11". Step values can be represented as a sequence, i.e. "0-59/15", "1-31/3", or "*/2". Names can be used for the "month" and "day of week" fields. Use the first three letters (case-insensitive) of the particular month or day. Ranges or lists of names are not allowed. The actual command you wish to execute is the sixth field of a cron table entry. Some examples of complete cron entries are show below:
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:
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 "
Cron Tutorial: Clearing Your Log Files
You can easily define a simple cron table entry in your cronjobs file
to nuke your log files. The instructions included below guide you through
this process step by step.
This will run the command "/usr/local/bin/vnukelog" (which clears all
of your log files) at 1 AM on the first day of the first month of
every quarter, or January, April, July, and October (1-12/3).
Obviously, you will need to substitute a valid e-mail address in the
place of "USER@YOUR-DOMAIN.NAME".
If you have created this file on your local computer, FTP the file
up to your Virtual Server and store it in your home directory under
the name "cronjobs" (you can actually use any name you would like).
Or if you used a name other than "cronjobs", substitute the name
you selected for the occurrence of "cronjobs" above.
NOTES
¹ - a daemon is a server process initiated at boot time that waits
in the background until its service is required.
² - it is possible to turn the logging capability of your web server
off. You can find out more information about turning off the logging
capability of your web site in the iServer Support Staff
Commonly Asked Question Archive.
| ||||||||||||||||||||||
| |||||||||||||||||||||||