May 16, 2008

Cron Jobs - Cron Jobs In Cpanel - Cron Jobs : Cron Jobs using PHP

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials
Pages: 1, 2, 3

free web hosting

Cron Jobs - Cron Jobs In Cpanel - Cron Jobs : Cron Jobs using PHP

OpaQue
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 :-

[ smile.gif This tutorial is for noobs, Dont go into detail. Just do as instructed smile.gif ]

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 tongue.gif

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

 

 

 


Reply

alapidus
QUOTE(OpaQue @ Jan 26 2005, 11:06 PM)
if tom wants to execute it every minute, he would use.

CODE
0 0 * * * /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php
*
cool tutorial, thanks a lot

but shouldn't you use * * * * * for the time if you wanted it to run every minute?

Reply

shyam
Errr... what's a cron huh.gif

Reply

itsme
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.

Reply

Seņor Maniac
I do not think that my crons are working

Reply

Zaideu
QUOTE(shyam @ Jan 27 2005, 08:30 PM)
Errr... what's a cron  huh.gif
*


It does an action every "X smile.gif
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 smile.gif You can insert some SQL requests on your file update.php, and it will be done everyday.
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 smile.gif

 

 

 


Reply

maddog39
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?

Reply

Zaideu
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 ! biggrin.gif It can be useful but it isn't essential. If you don't need it, don't use it smile.gif

Reply

maddog39
OK. Ya I dont think id have any use for it but just wondering. biggrin.gif

Reply

Roly
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.

Reply

Latest Entries

Trap FeedBacker
re: where is the mistake?
Cron Jobs - Cron Jobs In Cpanel

Tenzin, is this a test? the first thing I noticed is .Php and .Txt for an extension... Thats kinda funky. The second is your chmod. 755 is for folders, try 644 for your files.

Also, food for thought, making a call to file_put_contents will create the desired file if it doesn't exist. So, this file should have the correct chmod at creation. You can use this to verify the correct chmod for your files.

Hope that halps

-reply by riin

Reply

Trap FeedBacker
Watch out for some hosts running shared servers with cpanel. Some have a limit to how many crons you can have and at what rate they are allowed to go off. I just found out the hard way that my host only allows 5 crons at no less then every 15 min. My cron use was suspended for about 24hrs. The funny thing is it isn't mentioned anywhere, well maybe somewhere amongst the 100 page user agreement, but no where on the site. It just says, to use every minute use *****.

Anywho, what exactly is the '/usr/local/bin/php' used for and is it needed? also, I'm getting errors in my email that state the script cant find my required files. Anyone know why this would be?

Thanx

-reply by ryan

Reply

Trap FeedBacker
path to php
Cron Jobs - Cron Jobs In Cpanel

Hi. Can someone please tell be how to find the path to php. I'm uusing cpanel

In the past, I found a post that had a command to put in a page, to display the path. Does anybody know. It was really helpfull, just cant find it now. Thanks pat

Reply

x-plosive
hi i am creating my own textbased games using mccodes v2 but i need sum help with the crons i belive it use's curl but i tried typing that in the command box{curl http://www.corrupted.exofire.net/cron_hour...a5cdd16647c77e} it didnt work if i wanted to exicute this http://www.corrupted.exofire.net/cron_hour...ca5cdd16647c77e at a x amount of times what should i type in command box by the way using cpannel please help i am a total noob to crons jobs



Thanks In Advance biggrin.gif biggrin.gif

Reply

Trap FeedBacker
I have this on my cpanel:

/usr/bin/crontab permissions are wrong. Please set to 4755

Is it an error ? and how can I resolve this problem? where to put this dir and so on..

Please help

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2, 3
Recent Queries:-
  1. delete files script cpanel cron job - 3.93 hr back.
  2. cpanel cron args - 5.18 hr back.
  3. cpanel cron help - 6.91 hr back.
  4. cpanel root cron job - 7.72 hr back.
  5. how to setup a cron job run every minute - 8.74 hr back.
  6. cpanel set cron - 9.34 hr back.
  7. cpanel cron file location - 9.68 hr back.
Similar Topics

Keywords : cron jobs cron jobs cpanel cron jobs cron jobs php

  1. Cpanel Preinstalled Scripts, Extras, And Cpanel Options - Part 6 of My 7 Part Tutorial (1)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5:
    Advanced Tools Part 7: Fantastico Detailed Cpanel Tutorial Part 4: PreInstalled Scripts,
    Extra, and Cpanel Options In this tutorial I will, in detail explain all of th...
  2. Cpanel Fantastico - Part 7 Of My 7 Part Tutorial (14)
    This tutorial is going to discuss the entire list of fantastico features that are on the trap17
    servers This is an extention of my origional 6 part tutorial, now 7 part tutorial. The links to the
    rest are listed below. This tutorial is a follow-up to the Cpanel Tutorials that i wrote last
    night, the links can be found below. Part 1: E-mail Management Part 2: Useful Site Management
    Tools Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced
    Tools Part 6: PreInstalled Scripts, Extras, and Cpanel Options Detailed Cpanel Tutor...
  3. Ftp And Cpanel For Dummies - (7)
  4. How To Save Upload Time In Cpanel - (37)
    Do not Extract files and then upload them by ftp, try the following (1)open the file manager
    (2)upload the zip or gz format file (3)then extract the file it save the comulation time for
    ftp client and the ftp server....
  5. Cpanel Mysql Database Management - Part 2.1 Of My 7 Part Cpanel Tutorial (6)
    This tutorial is an extension to my 7 tutorial series about the Cpanel. The 7 different Cpanel
    tutorials can be found below. Part 1: E-mail Management Part 2: Useful Site Management Tools
    Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part
    6: PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel
    Tutorial Part 2.1: MySQL Management In this tutorial, i will explain how to add, edit, delete
    and over-all manage the MySQL Feature in the Cpanel. Creating a MySQL Database 1) ...
  6. Cpanel Advanced Tools - Part 5 of My 7 Part Tutorial (20)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 6:
    PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial
    Part 4: Advanced Tools In this tutorial I will, in detail explain all of t...
  7. Ftp Account Management - Part 2.2 of my 7 Part Cpanel Tutorial (0)
    This tutorial is an extension to my 7 tutorial series about the Cpanel. The 7 different Cpanel
    tutorials can be found below. Part 1: E-mail Management Part 2: Useful Site Management Tools
    Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part
    6: PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel
    Tutorial Part 2.2: FTP Management For this tutorial, you will need to locate the Icon under
    Site Management Tools labeled FTP Manager and also inside of the FTP:// Accounts area...
  8. Cpanel E-mail Management Set-up - Part 1.1 of My 7 Part Cpanel Tutorial (0)
    This tutorial is an extention to my 7 tutorial series about the Cpanel. The 7 different Cpanel
    tutorials can be found below. Part 1: E-mail Management Part 2: Useful Site Management Tools
    Part 3: Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part
    6: PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel
    Tutorial Part 1.1: E-mail Management In this tutorial i will, in detail explain all of the
    uses for the E-mail Section of the Cpanel. Then, if this is your first time in the cpane...
  9. Cpanel Analysis And Log Files - Part 4 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 3: Useful Site Management Tools2.1 Part 5: Advanced Tools Part 6:
    PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial
    Part 3: Analysis and Log Files In this tutorial I will, in detail explain all ...
  10. Cpanel Useful Site Management Tools 2.1 - Part 3 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
    Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2.1:
    Useful Site Management Tools In this tutorial I will, in detail explain all of th...
  11. Cpanel Useful Site Management Tools - Part 2 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 3: Useful Site
    Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
    Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2:
    Useful Site Management Tools In this tutorial I will, in detail explain all of t...
  12. Cpanel E-mail Management - Part 1 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 2: Useful Site Management Tools Part 3:
    Useful Site Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6:
    PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial
    Part 1: E-mail Management In this tutorial I will, in detail explain all of th...



Looking for cron, jobs, cron, jobs, cpanel, cron, jobs, cron, jobs, php

Searching Video's for cron, jobs, cron, jobs, cpanel, cron, jobs, cron, jobs, php
advertisement



Cron Jobs - Cron Jobs In Cpanel - Cron Jobs : Cron Jobs using PHP



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE