Suresh Thapa / Programmer / Web

Thursday, November 22, 2007

CRON JOBS

The CRON Command is in the Following Format:
[ Minute - Hour - Day - Month - Weekday ] - Command

The COMMAND, can be broken down in:
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]

So the COMPLETE CRON command can be written as:
[ Minute - Hour - Day - Month - Weekday ] [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]

The timing is spedified using * symbols:
* * * * * => 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

Since this is a UNIX command, You will have to Mention the PATH of PHP:
PATH TO PHP : /usr/local/bin/php
~OR~
PATH TO PHP : /usr/bin/php

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, which is most commonly used:
-a Run interactively
-b | Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c | 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 Parse . 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 Load Zend extension .

The Path of the PHP file Must be Complete absolute path.
If your USERNAME is "shoorace", Your path will be:
/home/shoorace/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 "shoorace" wants to execute my script "autotrigger.php" every hour. And it is stored in "public_html/cron/autotrigger.php".
Here, is cron is user created folder, ie not default.

So the Complete CRON command for every hour would be ,
0 * * * * /usr/bin/php -q /usr/home/shoorace/public_html/cron/autotrigger.php


Snapshot for cpanel >
Advanced (Unix Style):

2 Comments:

Blogger Rajesh Tandukar said...

This is very useful information for all web developers... Thanks for such informative stuff.

9:52 AM

 
Anonymous Anonymous said...

म एडम्स KEVIN, Aiico बीमा plc को एक प्रतिनिधि, हामी भरोसा र एक ऋण बाहिर दिन मा व्यक्तिगत मतभेद आदर। हामी ऋण चासो दर को 2% प्रदान गर्नेछ। तपाईं यस व्यवसाय मा चासो हो भने अब आफ्नो ऋण कागजातहरू ठीक जारी हस्तांतरण ई-मेल (adams.credi@gmail.com) गरेर हामीलाई सम्पर्क। Plc.you पनि इमेल गरेर हामीलाई सम्पर्क गर्न सक्नुहुन्छ तपाईं aiico बीमा गर्न धेरै स्वागत छ भने व्यापार वा स्कूल स्थापित गर्न एक ऋण आवश्यकता हो (aiicco_insuranceplc@yahoo.com) हामी सन्तुलन स्थानान्तरण अनुरोध गर्न सक्छौं पहिलो हप्ता।

व्यक्तिगत व्यवसायका लागि ऋण चाहिन्छ? तपाईं आफ्नो इमेल संपर्क भने उपरोक्त तुरुन्तै आफ्नो ऋण स्थानान्तरण प्रक्रिया गर्न
ठीक।

3:28 AM

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home