Laravel has an Ideas Github area where you can use the issue tracker to propose your ideas for future changes to the framework, and a few weeks ago Brian Dillingham threw out the idea to improve how schedule:run works locally. Mainly when you want to test your schedules without dealing with CRON locally.
From this discussion, Illia Sakovich submitted a pull request to add a brand new “schedule:work” command and it’s now merged and in the latest Laravel release.
schedule:work
The new schedule:work command mimics an every minute CRON Tab and calls schedule:run directly every minute, and here is the code that drives it:
public function handle(){ $this->info('Schedule worker started successfully.'); while (true) { if (Carbon::now()->second === 0) { $this->call('schedule:run'); } sleep(1); }}
It’s simple and pretty smart. Basically it keeps running and each minute when the seconds are 0 it fires schedule:run. Then once you are done with your testing just cancel it on the terminal with Ctrl+c.
This will be a big help for testing all your scheduled commands locally.