Search code examples
phpcurlcronhost

can execute php file from browser but cron job get fatal error on shared server hostgator


I can execute my php scrape file by typing in the address bar:

domain.com/scrape.php

However, I try to use cron job on my shared server on host gator by this command:

/usr/bin/php-cli public_html/scrape.php

I got this error message: Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in /home4/username/public_html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78 I already update my php version to stable 5.6 or even 5.7 version also same error. I think that it should not be php version error because I still can execute the file from browser right ? Also I cannot reboot server Apache because hostgator support said they cannot reboot it until the server is totally down... Any help please ! Thank you !


Solution

  • I ran into this problem last week on my own server. As it turned out, my browser was looking at one installation of PHP and cron was looking at a 2nd installation of PHP. One way to check is to run a PHP script through your browser that executes phpinfo(). That will tell you what the browser is running. Have cron do the same and save the results. Compare the two and make sure they're pointing to the same installation of PHP. Don't just check versions. Check install paths and loaded modules. Cheers.