IndexController
IndexController

Reputation: 589

How to use cronjob

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.

Upvotes: 1

Views: 302

Answers (3)

jrglasgow
jrglasgow

Reputation: 91

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

Upvotes: 4

cobbal
cobbal

Reputation: 70703

"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

Upvotes: 0

Richard Simões
Richard Simões

Reputation: 12791

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

Upvotes: 1

Related Questions