Schedule things

You can schedule things to run daily/hourly in a lot of different structures.

You can schedule an artisan command, a Job class, an invokable class, a callback function, and even execute a shell script.

1use App\Jobs\Heartbeat;
2 
3$schedule->job(new Heartbeat)->everyFiveMinutes();
1$schedule->exec('node /home/forge/script.js')->daily();
1use App\Console\Commands\SendEmailsCommand;
2 
3$schedule->command('emails:send Taylor --force')->daily();
4 
5$schedule->command(SendEmailsCommand::class, ['Taylor', '--force'])->daily();
1protected function schedule(Schedule $schedule)
2{
3 $schedule->call(function () {
4 DB::table('recent_users')->delete();
5 })->daily();
6}

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord