Cannot use Console operations for cronjobs

Your software
My Mautic version is: Cannot find anywhere (update to 3.3.3 is suggested in Dashboard)
My PHP version is: 7.4
My Database type and version is: MySql 8.0.25-0ubuntu0.20.04.1
Your problem
My problem is:

I have a running Mautic installation ( self hosted Ubuntu 20.04, NGINX) connected to Amazon SES. I just can send segment email. I wanted to set up cronjobs as described in the manual but I discover that Console command is refusing to work. When I go to Bin directory where Console is residing and type any of the console commands like:

console mautic:campaigns:update 

or

 console cache:clear

I get following error:

console: Unable to connect to 127.0.0.1:3109

These errors are showing in the log:

[2021-08-11 13:09:46] mautic.DEBUG: CONTACT: Tracking session for contact ID# 26969 through GET /email/6101723e245ef250694932.gif
[2021-08-11 13:09:49] mautic.DEBUG: CONTACT: 26969 set as current lead.
[2021-08-11 13:09:49] mautic.DEBUG: CONTACT: Tracking session for contact ID# 26969 through GET /email/6101723e245ef250694932.gif
[2021-08-11 14:12:01] mautic.DEBUG: CONTACT: New lead created with ID# 72601.
[2021-08-11 14:12:01] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72601 through GET /index.php/media/images/avatar.png
[2021-08-11 14:12:01] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72601 through GET /index.php/media/images/avatar.png
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.pagehit(page / )
[2021-08-11 14:12:01] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72601 through GET /index.php/media/images/avatar.png
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Current contact ID# 72601
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.pagehit associations.
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.devicehit(page / )
[2021-08-11 14:12:01] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72601 through GET /index.php/media/images/avatar.png
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Current contact ID# 72601
[2021-08-11 14:12:01] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.devicehit associations.
[2021-08-11 14:24:56] mautic.DEBUG: CONTACT: 2883 set as current lead.
[2021-08-11 14:24:56] mautic.DEBUG: CONTACT: Tracking session for contact ID# 2883 through GET /emai

Steps I have tried to fix the problem: No idea

Please advise on solution.

The exact command started with php, right?

No, if I put php in front of this like

php console mautic:segments:update

I get following error:

PHP Fatal error: Declaration of Doctrine\DBAL\Driver\PDOConnection::query() must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed …$fetchModeArgs) in /var/www/html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 70

In PDOConnection.php line 70:

Compile Error: Declaration of Doctrine\DBAL\Driver\PDOConnection::query() must be compatible with PDO::query(string $query, ?int $fetch
Mode = null, mixed …$fetchModeArgs)

Some more stuff from the log:

[2021-08-11 15:21:37] mautic.DEBUG: CONTACT: 39066 set as current lead.
[2021-08-11 18:41:23] mautic.DEBUG: CONTACT: 3096 set as current lead.
[2021-08-11 18:41:23] mautic.DEBUG: CONTACT: Tracking session for contact ID# 3096 through GET /email/610d118550827357225497.gif
[2021-08-11 19:17:20] mautic.WARNING: PHP Warning - file_put_contents(/var/www/html/mautic/var/cache/prod/lastUpdateCheck.txt): failed to open stream: Permission denied - in file /var/www/html/mautic/app/bundles/CoreBundle/Helper/UpdateHelper.php - at line 197 {“overrideCache”:false,“cacheFile”:"/var/www/html/mautic/var/cache/prod/lastUpdateCheck.txt",“updateStability”:“stable”,“release”:"[object] (Mautic\CoreBundle\Helper\Update\Github\Release: {})",“data”:{“error”:false,“message”:“mautic.core.updater.update.available”,“version”:“3.3.3”,“announcement”:“https://github.com/mautic/mautic/releases/tag/3.3.3",“package”:“https://github.com/mautic/mautic/releases/download/3.3.3/3.3.3-update.zip”,“stability”:“stable”,"checkedTime”:1628709440}}
[2021-08-11 19:17:21] mautic.DEBUG: CONTACT: New lead created with ID# 72602.
[2021-08-11 19:17:22] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72602 through GET /index.php/media/images/avatar.png
[2021-08-11 19:17:22] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72602 through GET /index.php/media/images/avatar.png
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.pagehit(page / )
[2021-08-11 19:17:22] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72602 through GET /index.php/media/images/avatar.png
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Current contact ID# 72602
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.pagehit associations.
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.devicehit(page / )
[2021-08-11 19:17:22] mautic.DEBUG: CONTACT: Tracking session for contact ID# 72602 through GET /index.php/media/images/avatar.png
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Current contact ID# 72602
[2021-08-11 19:17:22] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.devicehit associations.

Anyone? Any help?

Im not answering, because I can’t say anything smart. It seems to be, that you have a php issue here, but I might be wrong. The fact that you cant issue a basic php command questions the integrity of the whole install.
But again: I might be wrong

I think I found what was the problem. At least for now.
Although in Mautic php version was 7.4, in CLI of Ubuntu there was php 8. Strange that Mautic does not see which version of php is on the host.

I downloaded 7.4 and downgraded to this version. Now the error seems to be gone.

1 Like