7
votes

I'm trying to set a cronjob to run every 20 minutes. This works manually:

php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php LONDON

I tried to use "crontab -e" and set it even to every 20 minutes with:

 */20 * * * * php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php LONDON

it was saved to /tmp/crontab.0xYhei9m/crontab

And it doesn't seem to work. What's wrong here?

EDIT:

Current stats:

*. cron is up and running:

root     31855     1  0 08:39 ?        00:00:00 /usr/sbin/cron

*. Running "crontab -l" shows:

*/20 * * * * /usr/bin/php /srv/www/mysite.co.uk/public_html/PP/Make_XML.php LONDON

And still no go. Again manually running the script works just fine.

4
Maybe the missing details from your question are the key for the answer. At first it's very interesting where's your crontab getting saved. - fabrik
What missing details? i use Debian 6 - Tom
Is the crontab running as the same user as when running the command manually? - Treffynnon
Don't know too much about crontab but that / is very interesting in your entry. Just checked my crontab and mine doesn't contain / at all. - fabrik
@Treffynnon yes it also said "root has no crontab installing crontab" - Tom

4 Answers

5
votes

is the cron daemon even running?

1
votes

it was saved to /tmp/crontab.0xYhei9m/crontab

Yes - that's the file you just edited - its NOT the file crond reads to fire jobs. Crontab whould then read this file, install the updated crontab in the location where crond looks for it and notify crond it needs to process the file.

Have you checked:

  1. crond is running?
  2. your uid is allowed to schedule cron jobs (usually via /etc/cron.allow / /etc/cron.deny)
  3. that the script really isn't being started by cron and failing due to a permissions error?
  4. that the version of crond you are using support $PATH and can find the executable?
0
votes

In case this is already online, try using wget instead of php, with the url instead of the path, ie.:

*/20 * * * * wget http://YOUR_IP/~YOUR_USER/PATH/Make_XML.php

or

*/20 * * * * wget http://mysite.co.uk/PP/Make_XML.php

First make sure the url works , just by opening it with a browser

Hope it helps!

-1
votes

Crontab doesn't know anything about PATH variable. So use absolute path to your php (/usr/bin/php for e.g.)/ You can run command which php to find your php path