|
|
|
|
![]() ![]() |
Jan 27 2005, 04:06 AM
Post
#1
|
|
|
Administrator ![]() Group: Admin Posts: 1,448 Joined: 11-June 04 From: Somewhere in Time & Space. Member No.: 1 |
How to setup Basic Cron Jobs.
Ok. Many people are yelling that they cannot configure the crons properly. Here is a short tutorial which will help you set them. I have tried my best to explain the concept but there can be more advanced configurations. Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file called maintanence.php every one hour. This is what you do :- [ The CRON Command is in the Following Format CODE [ Minute - Hour - Day - Month - Weekday ] - Command The COMMAND, can be broken down in CODE [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT] So the COMPLETE CRON command can be written as CODE [ Minute - Hour - Day - Month - Weekday ] [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT] The timing is spedified using * symbols CODE * * * * * => Execute every minute 0 * * * * => Execute every Hour 0 0 * * * => Execute every mid-night 0 0 0 * * => Execute every Month 0 0 0 0 * => Execute every Weekday If you did not understand anything till now.. Good, this means you are a noob.. Read ahead Since this is a UNIX command, You will have to Mention the PATH of PHP. At Astahost, CODE PATH TO PHP : /usr/local/bin/php ( it also same at trap17, if users over there want to use it ) These are the Possible Command line Arguments you can use. This will effect the output. In our case, we will use the -q ( Quiet mode ) argument. CODE -a Run interactively -b <address:port>|<port> Bind Path for external FASTCGI Server mode -C Do not chdir to the script's directory -c <path>|<file> Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f <file> Parse <file>. Implies `-q' -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -q Quiet-mode. Suppress HTTP Header output. -s Display colour syntax highlighted source. -v Version number -w Display source with stripped comments and whitespace. -z <file> Load Zend extension <file>. The Path of the PHP file Must be Complete absolute path. If you have an Account at TRAP, And your USERNAME is "tom", Your path will be "/home/tom/public_html/" I assume you are familier with the PUBLIC_HTML directory. That is the Root folder where you store your html files. So lets say that Tom wants to execute my script "maintenance.php" every hour. And it is stored in "public_html/cron/maintenance.php"; So the Complete CRON command would be, CODE 0 * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php If tom wants to execute it every minute, he would use. CODE * * * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php If tom wants to execute it every Month, he would use. CODE 0 0 0 * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php There are more Complex forms of Assigning the TIMINGS for these scripts. You can go to CPANEL => Cron Jobs => Standard and set exact time when the script will be executed. Also, this method used php, you can also use Curl . -OpaQue |
|
|
|
Jan 27 2005, 05:24 PM
Post
#2
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 74 Joined: 21-October 04 From: Connecticut Member No.: 1,870 |
QUOTE(OpaQue @ Jan 26 2005, 11:06 PM) if tom wants to execute it every minute, he would use. cool tutorial, thanks a lotCODE 0 0 * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php but shouldn't you use * * * * * for the time if you wanted it to run every minute? |
|
|
|
Jan 27 2005, 07:30 PM
Post
#3
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 45 Joined: 11-November 04 Member No.: 2,234 |
Errr... what's a cron
|
|
|
|
Jan 27 2005, 09:47 PM
Post
#4
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 14 Joined: 19-December 04 Member No.: 2,796 |
I have been looking for this information for some time now. Thanx!
All other Cron help was for experts. I could not figure the correct command and can now see what is ment by argument. Will be trying this info on my site. You see I need it to update information every 2 weeks. |
|
|
|
Jan 27 2005, 10:20 PM
Post
#5
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 272 Joined: 10-September 04 From: (>0_0)>oooO Hadoken Member No.: 1,068 |
I do not think that my crons are working
|
|
|
|
Jan 27 2005, 10:23 PM
Post
#6
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 88 Joined: 12-January 05 Member No.: 3,246 |
QUOTE(shyam @ Jan 27 2005, 08:30 PM) It does an action every "X When you have a file : update.php And you want to load it every day at midnight. You don't have to go on this page yourself. The cron does it and you don't have to do anything, it is really usefull Exemple : CODE update.php mysql_query("UPDATE members SET point = point + '1'"); If the cron is activated on the page update.php, everyday your members will get 1 more point |
|
|
|
Jan 27 2005, 11:00 PM
Post
#7
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
Ok, so I still dont get the point of cron jobs. Are they just server settings that allow you to execute a command within a set ammount of time?
|
|
|
|
Jan 28 2005, 09:52 AM
Post
#8
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 88 Joined: 12-January 05 Member No.: 3,246 |
QUOTE(maddog39 @ Jan 28 2005, 12:00 AM) Ok, so I still dont get the point of cron jobs. Are they just server settings that allow you to execute a command within a set ammount of time? Exactly ! |
|
|
|
Jan 28 2005, 05:14 PM
Post
#9
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
OK. Ya I dont think id have any use for it but just wondering.
|