Where I talk about me, programming and other stuff that you will not read

Using CRON to run a PHP file

Setting up a CRON job to run a PHP script is not as easy as you would think. It all depends on your PHP installation and what modules are installed. Then you have to get the file to be run and parsed as PHP. However I have a method that works for most by using cURL.

Here is what I use to make my CRON job parse a PHP file without having to worry about changing locations of includes.

0,15,30,45 16 * * * php /usr/bin/curl --silent --compressed http://mywebsite.co.uk/cron.php


So what does that mean?

0,15,30,45 = The minutes of the hour that the script will run at.
16  = The hour of the day that the script will run at.
* = The day of the month that the script will run at. * means all.
* = The month that the script will run at. * means all.
* = The day of the week that the script will run at. * means all.

0,15,30,45 16 * * * php /usr/bin/curl --silent --compressed http://mywebsite.co.uk/cron.php
Will run my cron.php file every 15 minutes at 4pm every day.




Post a comment

New user? Thats ok you can still post.

Your name:
Your email:
A password:
Comment:

Web designer?

Twitter (follow)



I'm rocking out to

All that remains