======Cron Jobs====== The examples below represent various ways to set up a cron job for a Php script in a cPanel shared hosting environment. =====PHP Script on cPanel===== Some ways to run a PHP script with cron on cPanel: **wget** %%wget -O /dev/null http://www.domain.com/script.php%% **lynx** lynx is a text-based web browser commonly available on linux servers ([[http://en.wikipedia.org/wiki/Lynx_%28web_browser%29 wikipedia]]) %%lynx -dump 'http://www.domain.com/script.php'%% **php** note: this will not run the script as in a browser, which may lead to unexpected results. for instance, GET variables cannot be set in the url. %%php -q /usr/home/USERNAME/script.php%% %%/usr/bin/php -q /usr/home/USERNAME/script.php%% **GET** note: I've encountered shared hosting environments where GET is not available %%GET 'http://domain.com/script.php' > /dev/null%% =====Note on GET Variables===== If you want to include GET variables in your cron job (like me), put your url in single quotation marks. Otherwise, they will get cut off. An explanation can be found [[http://h5197.serverkompetenz.net:9080/abstracture_public/projects-en/cronnix/tips/ here]]: GET variables get truncated, so you have to wrap the url in quotes to make it work... This is because the shell will try to expand the arguments to 'open' and ? happens to be a shell wildcard character. =====Simple Test Script===== Upload this script to your server and set up a cron job to run it as a simple test: %% Cron Test"; if ( $_GET['cron'] = 'cron' ) echo '

GET ?cron=cron recognized

'; ?> %% =====References===== [[http://project1020.pbwiki.com/Tom's%20Whiteboard#cronjob Project 1020 Page]]