tags:

views:

115

answers:

3

I have my application hosted on a shared web host which uses cpanel. The control panel has a web interface to cronjob. I want to use cronjob to execute a file at a certain time everyday. The challenge am having now is the right command to enter in the "Command to run" text box. I'll be very glad if someone can help me out with this.

Thanks in advance.

+1  A: 

The "command to run" in a cronjob is nearly identical to running something from CLI. If you're running, say, an interpreted script, it would be something like:

/path/to/interpreter /path/to/script
BipedalShark
The interpreter i want to use is PHP. How do i get the path to it?
IndexController
It's typically either "/usr/bin/php" or "/usr/local/bin/php". You can also just invoke the alias: "php /path/to/script"
BipedalShark
A: 

"command to run" should be what program is executed at that time.

some examples:

/path_to_some_script_with_execute_permissions/script.sh

/usr/bin/php /path_to_script/script.php
cobbal
A: 

Optionally when cron is run on a web hosting platform, especially when you are using a php scripted website, your cron job would be regularly executing a script that you could run manually be opening the script in your web browser.

The way to do this is by using wget or curl to get the web page just like your browser would:

wget -qO /dev/null 'http://www.example.com/cron.php'

this tells wget to (q)uiet the output and send the (O)utput to /dev/null {the trash bin}, assuming that you don't need the output of the script saved, just the script run.

The same can be done with curl:

curl 'http://www.example.com/cron.php' > /dev/null

jrglasgow