I’m working on a system that is built with CakePHP 3.5, this system has multiple Cron Jobs that run throughout the day.
These cron jobs have always been executed in the following format:
/home/myuser/public_html/bin/cake shell_name command_name args
When the crons run they usually output their progress in the default system email that the server sends, for example:
Welcome to CakePHP v3.4.11 Console
---------------------------------------------------------------
App : src
Path: /home/myuser/public_html/src/
PHP : 5.6.31
---------------------------------------------------------------
Starting Thirty Minute Report Email Cron (JSON and PDF files)....
- Report 1 complete
- Report 2 complete
Report emails sent.
Cron Finished.
Yesterday, with no changes to the shell code (All I did was add the AWS SDK via composer, but I’ve tried reverting that and still the same), these crons have stopped working.
Now all that is output is the CakePHP 3.5 Shell Helper:
Welcome to CakePHP v3.4.11 Console
---------------------------------------------------------------
App : src
Path: /home/myuser/public_html/src/
PHP : 5.6.31
---------------------------------------------------------------
Current Paths:
* app: src
* root: /home/myuser/public_html
* core: /home/myuser/public_html/vendor/cakephp/cakephp
Available Shells:
[Bake] bake
[Migrations] migrations
[CORE] cache, i18n, orm_cache, plugin, routes, server
[app] console, backups, tasks
To run an app or core command, type `cake shell_name [args]`
To run a plugin command, type `cake Plugin.shell_name [args]`
To get help on a specific command, type `cake shell_name --help`
What is strange, is that if I run these commands via SSH (on the live production server) then they execute no problem, they also execute on localhost too.
I’m following the correct format as described in CakePHP docs, here’s my shell:
namespace App\Shell;
use Cake\Console\Shell;
use Cake\Core\Configure;
class TasksShell extends Shell {
/*****
*** SENDS THE REPORT EMAIL AT A THIRTY MINUTE INTERVAL
*****/
public function thirtyMinReport() {
/** CODE **/
}
}
and the cron being run is:
/home/myuser/public_html/bin/cake tasks thirty_min_report
Today I’ve also tried variations of it:
/home/myuser/public_html/bin/cake tasks thirtyMinReport
/home/myuser/public_html/bin/cake Tasks thirtyMinReport
php /home/myuser/public_html/bin/cake.php Tasks thirtyMinReport
cd /home/myuser/public_html && bin/cake Tasks thirtyMinReport
Doing a quick search of the CakePHP forums, I’ve found somebody also had the same issue as me, but it was unresolved… check it out here.
What can I be overlooking that is stopping the cron shell_name and command_name from being executed?