cakephp 3 Cron Job 在 cpanel 中不起作用 [英] cakephp 3 Cron Job not working in cpanel

查看:28
本文介绍了cakephp 3 Cron Job 在 cpanel 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 cakephp 3 shell 脚本中实现 cron 作业,但它在 cpanel 中不起作用.

I am trying to implement cron job in cakephp 3 shell script but it is not working in cpanel.

下面是我的 cron 工作代码 blog 是我的 cakephp 3 文件夹

below is my cron job code blog is my cakephp 3 folder

cd/home/mmentert/public_html/abc.com/blog &&bin/cake 你好主

cd /home/mmentert/public_html/abc.com/blog && bin/cake hello main

Cakephp 3 shell 类文件

Cakephp 3 shell class file

namespace AppShell;
use CakeConsoleShell;
use AppControllerUsersController;
class HelloShell extends Shell {
public function main() {
    $userinfo=new UsersController();
    $data=$userinfo->useremail();
    $this->out($data);
  }
}

推荐答案

我假设您使用的是共享主机,CakePHP 3 Docs 上建议的语法不适用于共享主机,这对我有用

I assume you are using shared hosting, the syntax suggested on CakePHP 3 Docs does not work for shared hosting, this is what worked for me

php -q -d register_argc_argv=on /home/public_html/bin/cake.php app main

cake.php 文件请使用您自己的路径

Please use your own path for cake.php file

  • -q --no-header 安静模式.禁止 HTTP 标头输出(仅限 CGI).
  • -d --define 为 php.ini 中允许的任何配置指令设置自定义值

希望有所帮助.

这篇关于cakephp 3 Cron Job 在 cpanel 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆