NetLab Small Business Solutions
Website Hosting Email Hosting Domain Names Website Design Website Development Client Support About NetLab

Knowledge Base

Search    
Browse by Category
Advanced Search Ask a Question



Solution: Running PHP scripts with Cron
Views: 710
Votes: 1

A crontab file consists of lines of six fields each. The fields are separated by spaces or tabs. The first five are integers that specify the following:

1. minute (0-59),
2. hour (0-23),
3. day of the month (1-31),
4. month of the year (1-12),
5. day of the week (0-6 with 0=Sunday).

The sixth field of a line in a crontab file is a string (command) to be executed by the shell at the specified times by the first 5 fields.

The job can be executed in either 2 ways.

1. If your PHP is installed using APACHE, then you can use the Lynx browser option. Lynx is a small web browser, generally available on Unix and Linux. Simply add the following command to your cron job.

* * * * * lynx -dump http://www.yourdomain.co.nz/cronjob.php

2. The other option is to execute the file locally. Add the following command to your cron job.

* * * * * /usr/bin/php -q /var/www/vhosts/yourdomain/httpdocs/cronjob.php



Others in this Category
Linux Hosting & Cron




Microsoft Windows.Net Server 2003 Microsoft SQL Server 2000 ASP.Net Linux php MySQL
PayPal Visa Mastercard
Copyright © 2006 NetLab. All prices in $NZD & exclude GST.