SCSI Hard Drives
Search
Advanced Search

Categories


Recently Viewed
Pages



My Links
Web Directory Index
A human edited, comprehensive web directory list.
Link Exchange
DesignFirms Link Exchange


Using Cron with PHP

By : sterex
Rating : Average Rating : 6.00 From 1 Voter(s)



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!








Comments / Feedback

pczpmail Email
November 16, 2007, 2:23 am

http://tutorial.jcwcn.com
Directory of tutorials for software programs such as MS Excel?photoshop and Macromedia Dreamweaver.
Adam Email
December 10, 2007, 6:11 am

Very useful crontab article indeed. Just what I was looking for. Thank you!
svetainiu kurimas Email
April 23, 2008, 9:04 am

Oh, it is good desision to automate scripts on a server or shell!
RSS 2.0: Syndicate this article

Add Comment
* Name


* Email Address


Site



*Image Validation (?)


*Comments / Feedback





Print Article Print Article Send to a friend Send to a friend Save as PDF Save as PDF Social Bookmarking
Add to: Mr. Wong Add to: Webnews Add to: Icio Add to: Oneview Add to: Folkd Add to: Yigg Add to: Linkarena Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: Simpy Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Spurl Add to: Google Add to: Blinklist Add to: Blogmarks Add to: Diigo Add to: Technorati Add to: Newsvine Add to: Blinkbits Add to: Ma.Gnolia Add to: Smarking Add to: Netvouz Information
Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent