Question - CRON issues

Hello,

I’m fighting some cron issues on a brand-new install:

I can run the cron jobs manually inside the cron docker container but the scheduled tasks are failing.

root@bb20cf039020:/var/www/eramba# /bin/sh /var/www/eramba/app/upgrade/bin/cake queue run -v
[2024-06-24 11:50:12] Looking for Job ...
Running Job of type "Reports.Report"
2024-06-24 11:50:12 debug: ------
2024-06-24 11:50:12 debug: Report (id:29) initialized with model: `Dashboard.DashboardReports`, type `1`, params `[  'user' => 'User::1',  'reportId' => (int) 29,  'dashboard' => true,  'preload' => true]`
2024-06-24 11:50:12 debug: Reports\Block\TextBlock (1071) initialized with config: `[  'size' => '12']`
2024-06-24 11:50:12 debug: Reports\Block\TaskListBlock (1052) initialized with config: `[  'size' => '4',  'type' => '2']`
2024-06-24 11:50:12 debug: Reports\Block\TaskListBlock (1067) initialized with config: `[  'size' => '4',  'type' => '1']`
2024-06-24 11:50:12 debug: Reports\Block\TaskListBlock (1081) initialized with config: `[  'size' => '4',  'type' => '3']`
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1075) initialized with config: `[  'size' => '12',  'model' => 'Risks',  'chartId' => '16',  'visualisations' => '1']`
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1068) initialized with config: `[  'size' => '12',  'model' => 'CompliancePackageRegulators',  'chartId' => '4',  'visualisations' => '1']`
2024-06-24 11:50:12 debug: Report (id:29) rendering
2024-06-24 11:50:12 debug: Reports\Block\TextBlock (1071) reading from cache
2024-06-24 11:50:12 debug: Reports\Block\TextBlock (1071) rendering
2024-06-24 11:50:12 debug: Reports\Block\TextBlock (1071) writing to cache
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1075) reading from cache
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1075) rendering
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1075) writing to cache
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1068) reading from cache
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1068) rendering
2024-06-24 11:50:12 debug: Reports\Block\ChartBlock (1068) writing to cache
Job Finished.
---------------------------------------------------------------
[2024-06-24 11:50:12] Looking for Job ...
nothing to do, sleeping.
^[---------------------------------------------------------------
[2024-06-24 11:50:22] Looking for Job ...
nothing to do, sleeping.
---------------------------------------------------------------
[2024-06-24 11:50:32] Looking for Job ...
nothing to do, sleeping.

\var\log\cron.log shows the following error:

su: invalid option -- 'v'
Try 'su --help' for more information.
su: invalid option -- 'v'
Try 'su --help' for more information.

crontab file:

@hourly export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job hourly >> /var/log/cron.log 2>&1
@daily export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job daily >> /var/log/cron.log 2>&1
@yearly export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake cron job yearly >> /var/log/cron.log 2>&1
* * * * * export $(cat /var/www/docker.env) && /bin/sh /var/www/eramba/app/upgrade/bin/cake queue run -v >> /var/log/cron.log 2>&1
## remember to end this file with an empty new line

Tried
chown www-data:www-data -R /var/www/eramba/
but that did not resolve the issue

Running the job as www-data yields a permission error:

root@bb20cf039020:/var/www/html# su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job hourly >> /var/log/cron.log 2>&1
" www-data
bash: line 1: /var/log/cron.log: Permission denied
root@bb20cf039020:/var/www/html#

making www-data the owner

chown www-data:www-data -R /var/log/chron.log

running the jobs manually as www-data

su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job hourly >> /var/log/cron.log 2>&1" www-data
su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job daily >> /var/log/cron.log 2>&1" www-data
su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake cron job yearly >> /var/log/cron.log 2>&1" www-data
su -s /bin/bash -c "/var/www/eramba/app/upgrade/bin/cake queue run -v >> /var/log/cron.log 2>&1" www-data

Some improvement, but daily still fails.

[2024-06-24 14:30:53] Looking for Job ...
nothing to do, sleeping.
2024-06-24 18:31:01 error: [Cake\Database\Exception\MissingConnectionException] Connection to Mysql could not be established: SQLSTATE[HY0
00] [2002] Connection timed out in /var/www/eramba/app/upgrade/vendor/cakephp/cakephp/src/Database/Driver.php on line 133
Stack Trace:
- /var/www/eramba/app/upgrade/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php:164
- /var/www/eramba/app/upgrade/vendor/cakephp/cakephp/src/Database/Schema/SchemaDialect.php:51

Hello,

Please follow the posting rules next time. You will have to give us more information, community or enterprise? Can you elaborate more on infrastructure? What is the host machine Linux distro? It is a server with a direct connection or there is something in front? What changes have been made to the default setup?