Additions:
note: I've encountered shared hosting environments where GET is not available
Deletions:
Additions:
**note:** I've encountered shared hosting environments where GET is not available
Additions:
The examples below represent various ways to set up a cron job for a Php script in a cPanel shared hosting environment.
%%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.
%%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.
Deletions:
Additions:
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.
Additions:
=====Simple Test Script=====
Upload this script to your server and set up a cron job to run it as a simple test:
%%
<?php
// a simple script to test cron jobs
echo "<h1>Cron Test</h1>";
if ( $_GET['cron'] = 'cron' ) echo '<p>GET ?cron=cron recognized</p>';
?>
%%
Upload this script to your server and set up a cron job to run it as a simple test:
%%
<?php
// a simple script to test cron jobs
echo "<h1>Cron Test</h1>";
if ( $_GET['cron'] = 'cron' ) echo '<p>GET ?cron=cron recognized</p>';
?>
%%
No Differences
Additions:
%%php -q /usr/home/USERNAME/script.php%%
%%/usr/bin/php -q /usr/home/USERNAME/script.php%%
%%/usr/bin/php -q /usr/home/USERNAME/script.php%%
Deletions:
Additions:
**wget**
%%wget -O /dev/null http://www.domain.com/script.php%%
%%lynx -dump 'http://www.domain.com/script.php'%%
**php**
%%php -q /home/serverpath/script.php%%
**GET**
%%GET http://domain.com/script.php > /dev/null%%
%%wget -O /dev/null http://www.domain.com/script.php%%
%%lynx -dump 'http://www.domain.com/script.php'%%
**php**
%%php -q /home/serverpath/script.php%%
**GET**
%%GET http://domain.com/script.php > /dev/null%%
Deletions:
Additions:
**lynx**
lynx is a text-based web browser commonly available on linux servers ([[http://en.wikipedia.org/wiki/Lynx_%28web_browser%29 wikipedia]])
lynx is a text-based web browser commonly available on linux servers ([[http://en.wikipedia.org/wiki/Lynx_%28web_browser%29 wikipedia]])