|
|
|
|
![]() ![]() |
![]() Group: Admin
Posts: 1,559 Joined: 11-June 04 From: Somewhere in Time & Space. Member No.: 1 myCENT:90.69 |
Post
#1
Jan 27 2005, 04:06 AM
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 |
![]() ![]() ![]() ![]() Group: Members
Posts: 74 Joined: 21-October 04 From: Connecticut Member No.: 1,870 |
Post
#2
Jan 27 2005, 05:24 PM
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 [right][snapback]43926[/snapback][/right]but shouldn't you use * * * * * for the time if you wanted it to run every minute? |
![]() ![]() ![]() Group: Members
Posts: 48 Joined: 11-November 04 Member No.: 2,234 |
|
![]() Group: Members
Posts: 14 Joined: 19-December 04 Member No.: 2,796 |
Post
#4
Jan 27 2005, 09:47 PM
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. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 272 Joined: 10-September 04 From: (>0_0)>oooO Hadoken Member No.: 1,068 |
|
![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 88 Joined: 12-January 05 Member No.: 3,246 |
Post
#6
Jan 27 2005, 10:23 PM
QUOTE(shyam @ Jan 27 2005, 08:30 PM) Errr... what's a cron [right][snapback]44206[/snapback][/right] 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 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
Post
#7
Jan 27 2005, 11:00 PM
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?
|
![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 88 Joined: 12-January 05 Member No.: 3,246 |
Post
#8
Jan 28 2005, 09:52 AM
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? [right][snapback]44280[/snapback][/right] Exactly ! |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 144 Joined: 24-July 04 From: Arizona Member No.: 189 |
Post
#10
Jan 28 2005, 11:09 PM
I have a question, what if we don't have a cpanel, where do we set up the cron job? This program has led me into making my own PHP cron >_> I have a MySQL table named "other" with fields "name'" and "content". CODE if(mysql_result(mysql_query('content','other','name = \'cron\' AND content <= UNIX_TIMESTAMP()-60*60*24'), 0)) { // cron stuff goes here // Update the cron time mysql_query('UPDATE other SET content = UNIX_TIMESTAMP WHERE name = \'cron\''); } This is sort of the way my script is, it's a good script 'cause it doesn't take much time out of the user. It's in the head file so it'll get run when needed. The cron stuff gets runned every day. |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
0 | OpaQue | 1,501 | 28th July 2004 - 07:51 PM Last post by: OpaQue |
|||
![]() |
1 | zachtk8702 | 281 | 10th August 2004 - 04:59 AM Last post by: X3r0X |
|||
![]() |
4 | odomike | 335 | 12th August 2004 - 05:20 AM Last post by: odomike |
|||
![]() |
5 | hatebreed | 684 | 26th August 2004 - 06:58 PM Last post by: wassie |
|||
![]() |
2 | zachtk8702 | 497 | 13th August 2004 - 04:26 PM Last post by: zachtk8702 |
|||
![]() |
1 | SilverBoarder | 260 | 17th August 2004 - 04:05 PM Last post by: odomike |
|||
![]() |
3 | Alpha | 294 | 16th September 2004 - 09:15 PM Last post by: Sjecht |
|||
![]() |
1 | NuHoaXuLa | 299 | 17th September 2004 - 06:01 AM Last post by: wassie |
|||
![]() |
2 | stevey | 423 | 24th September 2004 - 12:30 AM Last post by: akz |
|||
![]() |
1 | XtremeGamer99 | 230 | 22nd September 2004 - 08:34 AM Last post by: wassie |
|||
|
Lo-Fi Version | Time is now: 3rd December 2008 - 07:56 PM |