简体   繁体   中英

Running PHP script from cron

I am trying to run a PHP script through a cronjob . I already did this hundred of times, but now it's not working and I cannot figure out why.

I created a script called update_db.php in /var/www/html/ When I run the script by hand:

php /var/www/html/update_db.php

everything works fine. When I put this into a cronjob , it does nothing. My cronjob:

* * * * * /usr/bin/php /var/www/html/update_db.php

I tried to put a bash script in front of it that calls the PHP script, but, again, it only works when calling by hand, not from a cron.

There are no errors in the syslog. Also no mail in /var/mail . I restarted cron already, but no effect.

I use ubuntu 14.04.

Can anyone help me?

Is * * * * * php /var/www/html/update_db.php not working? You shouldn't need to use /usr/bin/php .

Also, check to make sure crons are running on your current system and that your files/directories have the appropriate permissions to be run by the cron.

CRON "should" be logging. Check the /var/log/cron, looking for your script errorrs or otherwise.

some implementations of cron need a full on restart - I have personanlly never had this issue, but I know fellow admins who have spent far too much time chasing fault, when a simple restart did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM