executing a sh script from the cron
I have a test.sh script
#!/bin/sh
php /home/v/file.php
sh /root/x/some.sh
when I execute the file as root from command line it works.
sh /home/v/test.sh
when I set it to crontab -e (is the root cron), is not working
* * * * * sh /home/v/test.sh
What do I do wrong? Thanks
The enviroment for cron to run into is very very limited, try to always use full path for binaries.
#!/bin/sh
/usr/bin/php /home/v/file.php
/bin/sh /root/x/some.sh
This considers that your php binary is in /usr/bin/php, please change that appropiately if it's not the case
Also try to add in top of your cron the MAILTO line in order to get a direct mail with any error that can happen during the execution
[email protected]
* * * * * sh /home/v/test.sh
It is probable the php
binary isn't in the default cron PATH. You should put the full path to your php binary in your script
/usr/bin/php /home/v/file.php
You should also provide a path for sh
/bin/sh /root/x/some.sh