500 error on cronjob v 4.0.1

Your software
My Mautic version is: 4.0.1
My PHP version is: 7.4
My Database type and version is: MySQL 8+

Your problem
My problem is: All cronjobs are showing same error in log

These errors are showing in the log:

Status: 500 Internal Server Error
Content-type: text/html; charset=UTF-8

Steps I have tried to fix the problem:
I maintain two servers. One for work and one private. The work server i only have access to cPanel while my private server, I have access to root, WHM and cPanel.

Both work and private server have similar hardware but the same OS CentOS7 and the same version cPanel, apache, php and applications etc.

I installed Mautic on work server but for some odd reason, none the cron job “console” would execute so I add a logging flag to cronjob this is the log that it gave me

Status: 500 Internal Server Error
Content-type: text/html; charset=UTF-8

Since I don’t have SU or root access on my work server, I decided to compress Mautic and export the database then install it on my private server only editing the local.php updating the domain name in it.

All cronjobs works right off the bat on my private server. I spent most of the day scratching my head checking and comparing permission on both server etc. I still cannot pinpoint why cronjob is giving a 500 error on the work server but works fine on my private server when both have similar setup.

Feedback greatly welcomed … I could use all the help on this one!

All functions in Mautic seems to be working but the cron jobs like updating segment or updating other functions are not working right now on the work server. The Segment won’t even update at the load of the web browser after I create several filters for contact list but it works fine on my private server even without the cronjob string somehow.

How are file permissions and ownership set? Did u set it on your work server according to the web user?

It’s a cPanel so it have to be set up with 644 as the permission. When I uncompress it, it will set up the correct user/group owner by the cPanel ID number that is assigned to the account.

I have two cPanel server with the same CentOS7 and I duplicated the source and database on both server. On both server I set up using this cron job string

php /home/(accountname)/(domainname)/bin/console mautic:segments:update >/home/(accountname)/mautic/cronjobs/segments_update.log 2>&1

My private server had no issue running the cron job but the work server gave an internal 500 error

I changed the string to by providing the full path to php74 bin

/opt/cpanel/ea-php74/root/usr/bin/php /home/(accountname)/(domainname)/bin/console mautic:segments:update >/home/(accountname)/mautic/cronjobs/segments_update.log 2>&1

Private server had no issue running the cron job

Work server does not produce the 500 internal error anymore but nothing is logged and the segments does not seem to be updated. The log file is blank now when it used to contain a 500 internal message with the “php” instead of full php path. I know the cron job is being executed because the log time stamp is updated every minute however still remain a blank file with no text or record on it.

The php only and full php path strings still works on my private server either way and it get logged each time a task is performed like this

Rebuilding contacts for segment 1
0 total contact(s) to be added in batches of 300
0 total contact(s) to be removed in batches of 300
0 contact(s) affected

Rebuilding contacts for segment 3
0 total contact(s) to be added in batches of 300
0 total contact(s) to be removed in batches of 300
0 contact(s) affected

Rebuilding contacts for segment 2
0 total contact(s) to be added in batches of 300
0 total contact(s) to be removed in batches of 300
0 contact(s) affected

Rebuilding contacts for segment 4
0 total contact(s) to be added in batches of 300
0 total contact(s) to be removed in batches of 300
0 contact(s) affected

I am still scratching my head on this one