Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

List scheduled commands in CLI in Laravel 8.x

Sometimes, it would be convenient if you get details regarding things right in your terminal. Take for instance, all your scheduled commands that you have defined in your application’s App\Console\Kernel class’ schedule method like so.

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('emails:send Amit --force')->daily();
    $schedule->exec('node /home/forge/script.js')->daily();
}

Wouldn’t it be nice if you could get the an overview of your scheduled tasks/commands and the details of when they are schduled to run next time, right into your terminal/CLI? Yes, right?

Well, the recent minor release of Laravel has just got that.

The schedule:list commmand

This PR in Laravel v8.19.0 has added a handy schedule:list Artisan command that can give an overview of your scheduled tasks and the next time they are scheduled to run.

For instance, when you run php artisan schedule:list in the console, it will list down all the scheduled commands in a tabular form like so.

As you can tell, the command reveals important information about the commands, their configuration and the next due to run in a nice tabular form.

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a

Tip

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?