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

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

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.

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

1 Response

  1. July 14, 2012

    […] the cron job with every 5 Minutes and set the attached […]

Leave a Reply

Your email address will not be published. Required fields are marked *