Configure and test Laravel Task Scheduling
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Configure and Test Laravel Task Scheduling
As a senior developer and technical blogger, you might encounter situations where you need to configure and test Laravel task scheduling. In this article, we'll cover the basics of configuring and testing your scheduled tasks in Laravel. We'll provide a clear explanation of each step, along with relevant code examples and best practices.
Description
We're trying to run a command every 1 minute using Task Scheduling in Laravel. This will help automate certain tasks or processes that require regular attention without the need for manual execution. Following these steps, your application can perform actions such as updating data or sending emails automatically.Attempt
We updated our crontab file to run every minute using this command: * * * * * php artisan schedule:run >> /dev/null 2>&1 In the Console/Kernel.php file, we changed it as follows:<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
$schedule->command('echo "Happy New Year!" ')->everyMinute(); //<---- ADD HERE
}
}
We added this line to the code: $schedule->command('echo "Happy New Year!" ')->everyMinute();