How do I execute a PHP file from CRON?

In order to execute a PHP file from the CRON, you need to add a line to your PHP script. It has to be the first line of your script and must contain your server's PHP executable location:

#!/usr/local/bin/php -q

As an example, the above line would go before the start of the PHP code:

#!/usr/local/bin/php -q
<?php

phpinfo();

?>


Now, in your cPanel area, click on the CRON and then the particular job you want to run. For the commnad line put in the following;

0 23 1 * * php /path/to/your/cron.php


* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

Please note, executing a crontab every MINUTE or every couple of minutes is a quick way to get your site suspended. Don't do it! Also, since crons run in the background, it's sometimes difficult to see how long something has been running. If you tie up system resources, it's another method in how your site can be suspended.

If you have questions about your CRON file, please contact support.

  • 0 brukere syntes dette svaret var til hjelp
Var dette svaret til hjelp?

Relaterte artikler

Can't access cpanel - How to open a port in Windows Live OneCare

If you are able to access your site, but not Cpanel, chances are that port 2082 is being...

Creating a MySQL Database using Cpanel

It's actually alot easier than you'd think. From the cpanel main page, click on mysql. Then:1)...

Hotlink Protection - Stop people from borrowing your imagery and bandwidth

One of the more popular methods of protecting the linking to your images is called "Hotlink...

How can I access my database from my computer?

Cpanel comes with many database access tools, and if your software package uses mysql, it will...

How can I make my own site backup?

The easiest way to make a website backup is via the Control Panel. When you log into the...

Powered by WHMCompleteSolution