Thursday, February 19, 2015

Debian webserver - Crontab error (not running php script)




I've a webserver with several sites and I'm trying to run a script by crontab but it gives me a error (126 and 127)



My script is in:




/var/www/site1/script.php




When I run the command:





php /var/www/site1/script.php




The script work as normal.



I've created a script.sh that contains





#!/bin/bash




/usr/local/php5/bin/php /var/www/site1/script.php





If I run





sh script.sh
Works




In crontab, I've entered this:




35 13 * * * /var/www/site1/script.sh





And I get this in syslog





Apr 12 13:35:01 webserver /USR/SBIN/CRON[13331]: (root) CMD (/var/www/site1/script.sh)



Apr 12 13:35:01 webserver /USR/SBIN/CRON[13330]: (CRON) error (grandchild #13331 failed with exit status 126)






What am I doing wrong?


Answer



You should try it this way



/usr/local/bin/php -q /path/to/your/script.php

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...