cakephp 3 Cron Job not working in cpanel

亡梦爱人 提交于 2019-12-18 09:01:27

问题


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

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

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

Cakephp 3 shell class file

namespace App\Shell;
use Cake\Console\Shell;
use App\Controller\UsersController;
class HelloShell extends Shell {
public function main() {
    $userinfo=new UsersController();
    $data=$userinfo->useremail();
    $this->out($data);
  }
}

回答1:


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

Please use your own path for cake.php file

  • -q --no-header Quiet-mode. Suppress HTTP header output (CGI only).
  • -d --define Set a custom value for any of the configuration directives allowed in php.ini

Hope that helps.



来源:https://stackoverflow.com/questions/38343673/cakephp-3-cron-job-not-working-in-cpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!