Skip to content

Conversation

dxnter
Copy link
Contributor

@dxnter dxnter commented Sep 10, 2025

Summary

This PR adds a --json flag to the schedule:list command to allow programmatic consumption of scheduled task data for monitoring and integration purposes. This is implemented in a way that aligns with other Laravel commands like route:list, model:show, event:list, and db:table.

JSON Output

[
  {
    "expression": "0 0 15 * *",
    "repeat_seconds": null,
    "command": "php artisan backup:run",
    "description": "Run daily backup process",
    "next_due_date": "2025-09-15 00:00:00 +00:00",
    "next_due_date_human": "5 days from now",
    "timezone": "UTC",
    "has_mutex": false
  }
]

Example Use Cases

  • Validate schedules after deployment
    • php artisan schedule:list --json | jq 'length'
  • Monitor critical tasks
    • php artisan schedule:list --json | jq '.[] | select(.command | contains("backup"))'
  • Transparency into automated processes in a user-friendly interface
    • $output = Artisan::call('schedule:list', ['--json' => true]);
      $schedules = json_decode(Artisan::output(), true);
      return view('admin.schedules', compact('schedules'));
    • @foreach($schedules as $schedule)
          <tr>
              <td>{{ $schedule['command'] }}</td>
              <td><code>{{ $schedule['expression'] }}</code></td>
              <td>{{ $schedule['next_due_date_human'] }}</td>
          </tr>
      @endforeach

@taylorotwell taylorotwell merged commit 6593e01 into laravel:12.x Sep 12, 2025
62 of 63 checks passed
tegos pushed a commit to tegos/laravel-framework that referenced this pull request Sep 28, 2025
* feat: add `--json` option to `schedule:list`

* formatting

---------

Co-authored-by: Taylor Otwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants