我正在使用CakePHP 3.5构建的系统,该系统全天运行多个CRON作业。
这些cron作业始终以以下格式执行:
/home/myuser/public_html/bin/cake shell_name command_name
当Crons运行时,他们通常会在服务器发送的默认系统电子邮件中输出其进度,例如:
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.
昨天,如果没有更改代码,这些Cron都停止了工作。
现在,输出的只是Cakephp 3.5外壳助手:
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`
什么很奇怪,是,如果我通过SSH运行这些命令(在实时生产服务器上(,那么他们也没有任何问题,他们也会在localhost上执行。
我正在遵循CakePHP文档中所述的正确格式,这是我的外壳:
namespace AppShell;
use CakeConsoleShell;
use CakeCoreConfigure;
class TasksShell extends Shell {
/*****
*** SENDS THE REPORT EMAIL AT A THIRTY MINUTE INTERVAL
*****/
public function thirtyMinReport() {
/** CODE **/
}
}
,正在运行的cr ran是:
/home/myuser/public_html/bin/cake tasks thirty_min_report
今天,我也尝试了它的变体:
/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
我还发现其他人在Cakephp网站上遇到相同的问题,但这仍然无法解决。
我可以忽略什么,这会阻止cron shell_name和command_name找到?
对于任何遇到麻烦的人,我都设法找到了这个答案。
由于我未知的某种原因,服务器PHP配置已更新,现在register_argc_argv
已设置为关闭。
我重新启用了这个,cron作业再次工作。
register_argc_argv = On
对/opt/alt/php56/etc/php.ini