Libcurl with OpenSSL not being found from cron
I have a command that runs fine from the terminal/command-line. However, when I try to run the same command as a cron job it fails. Here is the cron job
*/5 * * * * (PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/lib; /path/to/app/public_html/vendors/cakeshell report main -cli /usr/local/lib -console /path/to/app/public_html/cake/ console -app /path/to/app/public_html/app)
..and here is the error message:
Fatal error: Uncaught CurlException: 1: Protocol https not supported or disabled in libcurl thrown in path/public_html/app/vendors/facebook/graph/facebook.php on lin开发者_StackOverflowe 622
I have libcurl and --OpenSSL support installed. I am thinking this is a PATH issue. As you can see I've tried adding the path to PHP which I think is /usr/local/lib (from phpinfo()) but it is still failing.
I am completely stumped as to why this would work from terminal, but not cron. I don't think it's to do with the Facebook SDK (Graph) as it works outside cron. Does anyone have any ideas?
Found the solution. In phpinfo() find the $_SERVER['PATH'] variable under PHP variables, copy the contents of this and preappend it to your cron job as PATH. So
*/5 * * * * /home/worldDomination
would be
*/5 * * * * PATH=contents-of-$_SERVER['PATH'] ; /home/worldDomination
That's it.
精彩评论