Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cronjob php script not working

Tags:

linux

php

debian

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.

like image 415
Tom Avatar asked Mar 31 '11 11:03

Tom


People also ask

Why is my cron not working?

Check permissions Another user might have created the cron job and you may not be authorized to execute it. Note that the root must own jobs added as files in a /etc/cron. */ directory. That means that if you don't have root permissions, you might not be able to access the job.

Do Cronjobs run automatically?

The cron reads the crontab (cron tables) for running predefined scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.


2 Answers

is the cron daemon even running?

like image 108
Gnudiff Avatar answered Sep 28 '22 21:09

Gnudiff


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?
like image 21
symcbean Avatar answered Sep 28 '22 20:09

symcbean