Configure and test Laravel Task Scheduling

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

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

Question

How do I test this? How do I trigger my echo to display? How do I know if what I did is not wrong? To test your scheduled task, you can follow these steps: 1. Check the crontab file for any syntax errors or typos and ensure it runs as expected. 2. Restart your Laravel application to load the updated Kernel class. 3. Start a new terminal session and use the command "php artisan schedule:run" to execute all the scheduled tasks manually. This will show you if there are any errors in your scheduled tasks or code. 4. After testing, you can monitor your application logs for output from commands running as part of the task scheduling process. Make sure they're displaying correctly and performing the desired actions. 5. If everything appears to be working correctly, run the crontab file as normal to keep your scheduled tasks running on a regular basis. These steps should ensure that your Laravel Task Scheduling is properly configured and tested. Keep in mind, it's always necessary to monitor your logs for any errors or unusual behavior so you can quickly troubleshoot any issues if they arise.