tags:

views:

111

answers:

2

Hello,

I want to execute a script every 30mins, but i want to use it through cron as it is my personal script which emails me updates from various sites depending on configurations.

So what should i write in Command to run in cpanel to execute my script with name check.php

+1  A: 

The format is something like this. Eactly the same as if you were trying to run the command from the terminal.

    php_location full_script_location output_location

So for example on my server I would use something like this:

/usr/bin/php /home/yacoby/status/check.php

You need to make sure your email address is set correctly.

If you don't want it to email you the output from the script (i.e. you want to log it, or do the emailing from within the script), put > /dev/null at the end of the command. eg.

/usr/bin/php /home/yacoby/status/check.php > /dev/null
Yacoby
Since your script will be running on the shell, you should be using `php-cli`.
Andrew Moore
in cPanel cron I do "php /home/usr/status/check.php" no need for "/usr/bin/php". To see if it works you can do simple test also by adding in cron job the following "php -v" it should send you via email the PHP version and a bunch of other details.
Marco Demajo
@Shishant: if your hosting provider uses suPHP Apache module to let you define your php.ini configuration (which is quite common in nowdays), remember that when calling the script with php command the suPHP configuration will be ignored and the current server php.ini configuration will be used instead. In order to make the cron job to use suPHP module the wget command suggested by Richy C. seems to be the only way to go.@
Marco Demajo
Marco Demajo
+1  A: 

You could also try:

wget http://www.example.com/check.php

as then your script will run in exactly the same way it would on the website (environment variables, file permissions etc will be the same).

Richy C.