In addition to the helpful links supplied by Angelo95210, I have direct experience running PHP scripts via cron on our Linux server.
All of the following is via CLI (command line interface, i.e. a shell):
Step 1: Write your PHP script and make sure it can run without errors via CLI using full paths, i.e. if you typed in manually:
Code:
$> /path/to/php /path/to/yourscript.php
Note: If you're not sure of the path to PHP, type in "which php"
Step 2: To EDIT the crontab type in "crontab -e"
To run this at 12:00am add the following:
Code:
# Yourscript.php runs 12:00 every day (this is a comment)
0 0 * * 0 /path/to/php /path/to/yourscript.php
Two optional commands to add into crontab are:
1) Time zone i.e. "TZ=EST5EDT" - use whatever is local to you (see possible time zones in /usr/share/zoneinfo/ on most *nix systems)
2) E-Mail all crontab output to you, i.e. "MAILTO="yourname@yourdomain.com"
Step 3: Save and exit the editor
To LIST the crontab to ensure it was updated properly, type in "crontab -l"
Obviously, use your real paths - the above example code is for syntax demonstration purposes.
-jim