Tom
Tom

Reputation: 9653

Cronjob php script not working

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.

Upvotes: 7

Views: 1482

Answers (4)

symcbean
symcbean

Reputation: 48387

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?

Upvotes: 1

Cristian
Cristian

Reputation: 198

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!

Upvotes: 0

Emmerman
Emmerman

Reputation: 2343

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

Upvotes: -1

Gnudiff
Gnudiff

Reputation: 4305

is the cron daemon even running?

Upvotes: 5

Related Questions