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);
}
}
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