Im running ubuntu server, and im trying to run a script every hour. What I tried is:
sudo crontab -e
and then I add this to the end of the file:
MAILTO="info@email.com"
30 * * * * /usr/bin/php /var/www/scripts/cronscript.php
The script doesnt seem to be running, and im not getting the email.
What am I doing wrong?
using:
30 * * * * /usr/bin/wget "http://example.com/scripts/cronscript.php"
worked for me
Use the -f
flag of php to tell it to take that file as input:
MAILTO="info@email.com"
30 * * * * /usr/bin/php -f /var/www/scripts/cronscript.php
That is, of course, if your php is actually located at /usr/bin
You can also use cURL, like this:
curl http://foobar.com/scripts/cronscript.php
If you need it to run silently:
curl --silent http://foobar.com/scripts/cronscript.php
To add Gzip handling:
curl --compressed http://foobar.com/scripts/cronscript.php
I usually use both, like: curl --silent --compressed http://foobar.com/scripts/cronscript.php