To use cron, you must first set up a file of cron entries. This file can
actually be placed anywhere in your account you like, and have any name
you want. It should contain one entry for each action you want taken.
A cron entry looks similar to the following:
30 3 * /usr/bin/nice -20 /usr/home/username/script.php
In this case, the script "script.php" would be run nightly at 3:30 AM.
Between the fifth digit and the "/usr/bin/nice" we recommend putting a
literal "tab" character.
"/usr/bin/nice -20" utilizes the system nice command to lower the impact
of the call on the server.
PLEASE NOTE IN ORDER TO RUN A PHP CRON SCRIPT YOU NEED PHP TO BE INSTALLED LIKE STAND ALONE MODULE, NOT LIKE APACHE MODULE.
"/usr/home/username/script.php" is the full path to the script/program you
would like cron to run. You can also use regular UNIX commands here if
you like, using full paths to programs. For instance, you could have
30 3 /usr/bin/nice -20 /bin/rm /usr/home/username/temp/
to remove all files from some temporary directory you might have each
night at 3:30 AM, as in the earlier example.
The "30 3 *" requires a bit more explaining. The time a cron command
is executed is controlled by the 5 numbers that precede the cron
directive.
The first number is the minutes after the hour (0-59).
The second is the hour of the day (0-23, with 0 being 12 AM).
The third number is the day of the month (1-31).
The fourth is the month of the year (1-12).
The fifth is the day of the week (0-6, with 0=Sunday and 6=Saturday, etc).
A in place of any of the values matches all possibilities (for
instance, in the given example the script runs every day because the 's
for day of the month, day of the week, and month of the year match all
values).
Multiple values are separated by commas. For instance, you might start
with 15 1,3,5 * to run a script every day at 1:15, 3:15, and 5:15.
Once you have your cron directive file (say, cron.file) in your account,
you must connect via telnet and issue the command
crontab cron.file
using the name you gave the file. (Note that you must be in the same
directory as the cron file at the time.) After this, your cron should be
activated. If the programs running via cron generate errors, the cron
daemon will e-mail them to your account. If at any time you would like to
change your cron jobs, just edit your file, and rerun the crontab command
as shown above.
Sincerely.
SaS.