Setting up Cronjob causes Fatal Error


I wanted to setup Cronjobs in my 7.8.3 instance.

I’ve done the following:

sudo crontab -e -u www-data

and inserted:

          •    cd /var/www/live; php -f cron.php > /var/www/live/suitecrm.log 2>&1

Now in my suitecrm.log the following exception is caught:

PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/live/include/database/MysqliManager.php:284
Stack trace:
#0 /var/www/live/include/database/DBManagerFactory.php(147): MysqliManager->connect(Array, true)
#1 /var/www/live/include/entryPoint.php(179): DBManagerFactory::getInstance()
#2 /var/www/live/cron.php(45): require_once(’/var/www/live/i…’)
#3 {main}
thrown in /var/www/live/include/database/MysqliManager.php on line 284

Any hints on this?



Check your php.ini for database connection settings and modules.

But the trick is, check the php.ini that gets applied with the CLI version of PHP, which is where the cron job runs. It’s a different one from the Web server version of PHP, which runs the SuiteCRM app.

If SuiteCRM runs correctly but cron fails to connect to the database, this should be the cause…

In the command-line, just run this to see which php.ini your cron job is using:

php -i | grep php.ini