Thursday, October 18, 2007

cron job in php



Cron job is a system method to run a particulat task/page to a particular interval. It si a automated system process.
here the steps to install

On UNIX/Linux:
Use the cron daemon to execute the "runcronjobs.php" file.
Edit the desired crontab file and add the following lines:

# This must be set to the directory where eZ publish is installed.

EZPUBLISHROOT=/path/to/your/ezpublish/directory



# Location of the PHP Command Line Interface binary.

PHP=/usr/local/bin/php



# Executes the runcronjobs.php script every 15th minute.

0,15,30,45 * * * * cd $EZPUBLISHROOT; $PHP -C runcronjobs.php -q 2>&1

Shows current cron file contents

crontab -l

Replaces your current cron file

crontab /path/to/your/ezpublish/directory/ezpublish.cron

On Windows:
On Windows 2000 and XP it is possible to use the "Scheduled Tasks" mechanism to automatically run the maintenance file. You would probably have to create a batch (.bat) file (which is set up to run the runcronjobs.php file with the correct parameters, etc.) and then set up

------------ Version 3.4 update ----------

Usage: runcronjobs.php [OPTION]... [PART]

Executes eZ publish cronjobs.



General options:

-h,--help display this help and exit

-q,--quiet do not give any output except when errors occur

-s,--siteaccess selected siteaccess for operations, if not specified default siteaccess is used

-d,--debug display debug output at end of execution

-c,--colors display output using ANSI colors

--sql display sql queries

--logfiles create log files

--no-logfiles do not create log files (default)

--no-colors do not use ANSI coloring (default)

Example: Run all cronjobs in cronjob.ini
runcronjobs.php

Example: Run a subset. i.e. I only want to run workflow. A good idea as link checking every ten minutes is just a waste of cpu and bandwidth
This example will run the workflow elements configured by adding the following to you cronjob.ini file.

[CronjobPart-workflow]

Scripts[]=workflow.php



runcronjobs.php workflow

No comments: