Cron job not registered error in Laravel
Cron job is a Linux command for scheduling task to executed at a fixed time in the future. Normally it is used to execute some tasks periodically. For example send a mail every Tuesday. Let’s look at a scenario in which the error log shows ‘No scheduled commands are ready to run’ error after a cron job is set to run once per day at 00:00 . The Laravel commands to set cron jobs are given below.
protected function schedule(Schedule $schedule) {
$schedule->command('command:daily-reset')->daily();
$schedule->command('command:monthly-reset')->monthly();
}
On the server set up the cron job to run at 00:00 everyday.
0 0 * * * php /home/privates/public_html/staging/current/artisan schedule:run
This error can occur if your commands are not registered. Running php artisan command will help to findout. If not registered it will show command:daily-reset and command:monthly-reset under the list of available artisan commands. If its not there then your command is not registered. You can register your commands by adding it to commands property in app/Console/Kernel.php.
protected $commands= [
'App\Console\Commands\YourFirstCommand',
'App\Console\Commands\YourSecondCommand'
];
Set crontab entry to:
* * * * * php/home/privates/public_html/staging/current/artisan schedule:run
Comments
0 comments
Please Sign in or Create an account to Post Comments