YetiForceCompany / YetiForceCRM

Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
https://yetiforce.com
Other
1.74k stars 749 forks source link

repeated cron.php corruption #13190

Closed jimlongo56 closed 4 years ago

jimlongo56 commented 4 years ago

Hello, every few days I wake up to find (or told by staff) about this error manifested usually in the following error displayed on the admin pages.
Screen Shot 2020-06-17 at 9 57 39 AM

Here is my config report and some more information. ConfReport

Environment Version / Name
YetiForce 'appVersion' => '5.3.0', 'patchVersion' => '2020.03.13',
Web server (name and version) Apache/2.4.43 (cPanel)
PHP 7.2
Browser (name and version) Chrome latest
Operating System (name and version) CentOS 7
Database (name and version) 10.3.23-MariaDB MariaDB Server

Additional NOTES: Have also seen the following error reported by cron occasionally, don't think it is directly related, but not sure about that yet.

/bin/sh: line 1: 23563 Bus error   /usr/local/bin/php -f cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1

As a fix, have moved the /app_data/cron.php file out of the way and let it be rebuilt. Here are examples of "bad" cron files, along with the latest good one. Also attached the error_log

Archive.zip

mariuszkrzaczkowski commented 4 years ago

It looks like problems in PHP CLI, run this script via WWW and CLI and attach the results. https://github.com/YetiForceCompany/YetiForceScripts/blob/master/TestRequirements/ConfReportTest.php the script generates the file: ConfReportTest_cron.html or ConfReportTest_www.html

mariuszkrzaczkowski commented 4 years ago

run in the same way as you call the cron

mariuszkrzaczkowski commented 4 years ago

copy to /home/yeti/public_html/public_html/ConfReportTest.php

jimlongo56 commented 4 years ago

Run as CLI returns nothing root@vps [~]# php /home/yeti/public_html/ConfReportTest.php

however did find this when I run via CLI

root@vps [/]# cat /home/error_log
[18-Jun-2020 13:35:13 UTC] PHP Fatal error:  Uncaught Error: Class 'App\Utils\ConfReport' not found in /home/yeti/public_html/ConfReportTest.php:25
Stack trace:
#0 {main}
  thrown in /home/yeti/public_html/ConfReportTest.php on line 25

When I Run via WWW I get this output on screen with the attached file generated.


snipped because it has no importance in the story

5.58375 

ConfReportTest_www.html.zip

mariuszkrzaczkowski commented 4 years ago

The script does not work, cron does not work properly, it means that you call it wrong or something is wrong with the php configuration in CLI

jimlongo56 commented 4 years ago

something?

mariuszkrzaczkowski commented 4 years ago

try cd _CRM_DIR and run php ConfReportTest.php or /usr/local/bin/php ConfReportTest.php

jimlongo56 commented 4 years ago
root@vps [/home/yeti/public_html]# php ConfReportTest.php

snipped because it's irrelevant

 <hr/> <hr/>0.67552 <hr/>root@vps [/home/yeti/public_html]#
jimlongo56 commented 4 years ago

P.S. I only get it to run if I'm in the _CRM folder.

IOW from ~ folder = nothing root@vps [~]# php /home/yeti/public_html/ConfReportTest.php

from /home/yeti/public_html/ = returns data [/home/yeti/public_html]# php /home/yeti/public_html/ConfReportTest.php

mariuszkrzaczkowski commented 4 years ago

Surely you have a problem with file permissions, not all files have the correct owner. Improve this recursion. You run CRON from the root user and it can't be done, it must be the same as the owner of the CRM files and the WWW server, e.g. www-data

jimlongo56 commented 4 years ago

okay made sure all files are owned by the same user:group sudo chown -R yeti:yeti /home/yeti/public_html/

still don't see why root can't run this file. root@vps [/]# whoami root root@vps [/]# php /home/yeti/public_html/ConfReportTest.php root@vps [/]#

Is this because these crons are in the main crontab file?

*/5 * * * * sh /home/yeti/public_html/cron/cron.sh > /home/yeti/public_html/cache/logs/cron.log 2>&1
*/5 * * * * php /home/yeti/public_html/cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1
*/5 * * * * cd /home/yeti/public_html/; /usr/local/bin/php -f cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1
vovpff commented 4 years ago

sudo -u yeti php /home/yeti/public_html/ConfReportTest.php

jimlongo56 commented 4 years ago

thanks @vovpff

attachment at end.

root@vps [/]# sudo -u yeti php /home/yeti/public_html/ConfReportTest.php
Content-type: text/html; charset=UTF-8

snipped because it's meaningless . . . 

 <hr/> <hr/>0.54949 <hr/>root@vps [/]#

ConfReportTest_www.html.zip

vovpff commented 4 years ago

@jimlongo56 no problem

rioshaz commented 4 years ago

@jimlongo56 i have the same problem.. this error comes once in a while every 4- 8 day.. any solutions man...

mariuszkrzaczkowski commented 4 years ago

run the cron in the same way

jimlongo56 commented 4 years ago

@mariuszkrzaczkowski okay a little too cryptic for me.

Do you mean that all these crons should be in crontab -u yeti ?

*/5 * * * * sh /home/yeti/public_html/cron/cron.sh > /home/yeti/public_html/cache/logs/cron.log 2>&1
*/5 * * * * php /home/yeti/public_html/cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1
*/5 * * * * cd /home/yeti/public_html/; /usr/local/bin/php -f cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1

Because using sudo - u yeti in the root crontab sounds odd.

vovpff commented 4 years ago

You need to run php from site owner user. You can put this to cron.sh

jimlongo56 commented 4 years ago

@vovpff , so:

*/5 * * * * sudo -u yeti php /home/yeti/public_html/cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1

in the root crontab?

I've also changed cron.sh to contain the exact correct path for this account. export USE_PHP=/usr/local/bin/ea-php72

and the last cron to also use that php explicitly. */5 * * * * cd /home/yeti/public_html/; /usr/local/bin/ea-php72 -f cron.php > /home/yeti/public_html/cache/logs/cron.log 2>&1

mariuszkrzaczkowski commented 4 years ago

Is the cron done to the end? you can call this via the url

jimlongo56 commented 4 years ago

Is the cron done to the end? How would I know this?

mariuszkrzaczkowski commented 4 years ago

you can check it from the panel https://gitdeveloper.yetiforce.com/index.php?module=CronTasks&parent=Settings&view=List

and in the database

image

jimlongo56 commented 4 years ago

https://github.com/YetiForceCompany/YetiForceCRM/issues/13190#issuecomment-646796591 seems to have fixed things.
Have not seen the error since then.

In other words, be very careful with which user and which PHP you are calling on a multi-php cPanel server