ANIL KUMAR PANIGRAHI 's Blog

What is cron job ? How to set the cron job in PHP?

Posted by: Anil Kumar Panigrahi in: ● April 6, 2009

1) Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it’s called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time.
For a developer we write code to run that particular code at a specific time using this cronjobs or Scheduled Tasks.

2) To set the cronjob :

In the cpanel of your web hosting server in that separate link called crontab,
in that we have to set the times and dates,

a) <?
echo $_SERVER['DOCUMENT_ROOT'];
?>

run this in php file we will get server document path ,

b) In that we have the form like minutes, hours, day, month, week, if have to set values to particular time and date otherwise input as * then it treated as every minute, then in the command section we should place the

[ Minute - Hour - Day - Month - Weekday ] [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]

In Some servers :
Example: /usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php

In some server we place like
Example : php -q /home/tom/public_html/cron/maintenance.php

In the file maintenance.php we will write the code which one have to execute in the Corn job functionality.


Share on Twitter

No Comments to "What is cron job ? How to set the cron job in PHP?"

Write Comment

About Me

  Anil Kumar Panigrahi
  Software Engineer (PHP)
  Blogger & Founder of Anil Labs
  Baruva, India

You can share with me . . .

My Own Contributions

1) First contribution for codeigniter framework ( multi language support using google translate API ). we can get files from http://github.com/nyros/codeigniter_multilanguage


2) Audio and Video Streaming using FFMpeg and PHP -complete doc file : http://www.docstoc.com/docs/8300349/Audio-and-Video-Streaming

Twitter Updates

Follow me @anil2u
  • We will always be thankful to our teacher for all the hard work and efforts they have put in, for educating us.- Happy teachers Day . . . :) - posted on 05/09/2010 05:39:13
  • Working on shipping cost functionality (UPS and USPS) for oscommerce shopping cart - posted on 01/09/2010 09:40:03
  • If your freedom hurts others, you are not free. You must not hurt others. - Vivekananda - posted on 31/08/2010 06:02:49
  • Another day starts with full of energy . Good Morning - posted on 31/08/2010 02:54:12
  • Nice explanation about php oops concept : http://youropensource.com/projects/182-OOPS-Concepts-in-PHP - posted on 30/08/2010 19:56:17