3

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);
  }
}
ndm
  • 59,784
  • 9
  • 71
  • 110
Sharma Vikram
  • 2,440
  • 6
  • 23
  • 46

1 Answers1

2

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.

MotsManish
  • 485
  • 1
  • 8
  • 16
  • Thank you, It is working great with me. How can I set multiple configuration directives? – gonzo Sep 12 '17 at 10:33