What is a cron anyway?
Cron is the name of program that enables unix users to execute commands or
scripts (groups of commands) automatically at a specified time/date.
In simple terms, Cron runs whatever script you specify at a regular time interval.? The possibilities for cron and php are many, but common applications are things such as mailing list, regular removal of temporary files, or updating pages.
In this tutorial, we will use the cron manager inside Cpanel
Before making the actual cron job, write the script you wish to use and thoroughly test it on the server.? Cron jobs that get stuck in infinite loops can cripple a server.? The first line of your script must include the path to php on your server (run phpinfo() and look for the fifth item down "Configuration File (php.ini) Path") and "-q". You first line should be similar to this:
|
#!/usr/local/Zend/etc/ -q |
Once the script is tested?choos "cron jobs" from your cpanel. Two options are now presented:standard and advanced.Choose standard.
Enter your e-mail where requested.? The output of your scipt will be sent here.
Place the following in the command line:
| php -f /home/b2l9999/public_html/my_script.php |
Note the path to your scipt.? Cron runs from the server root, so the path must be absolute (Check phpinfo() "DOCUMENT_ROOT" if you are unsure).? This also means any include() or require() function must refrence the absolute path to the included file.? Now select the appropriate settings for when the script is to run from the boxes below.
The advanced option is much the same as simple, only the time intervals must be entered manually.? The following are possible enteries (assume the minuetes column):
| * - a wildcard. it will update every minuete. |
| 5- an interger from 0-59 (or as appropriate for column).? it will update whenever the minuete is five |
| */5 - it will update every five minuetes |
Note the difference between "5" and "*/5". Assuming all other columns are "*", the first would occur once an hour, but the second would occur 12 times!


Search
Categories


Print Article
Save as PDF
November 16, 2007, 2:23 am
http://tutorial.jcwcn.com
Directory of tutorials for software programs such as MS Excel?photoshop and Macromedia Dreamweaver.