Laravel · Artisan Commands

Monitor Custom Laravel Artisan Commands

Schedule::command()->pingOnSuccess() covers jobs that run through Laravel's own scheduler. For an Artisan command invoked some other way — a deploy hook, a CI/CD pipeline, or manually via SSH — ping directly from inside the command itself instead.

Setup

1

Create an incoming monitor

Add a heartbeat monitor in Pingtastic for the command, with a grace period that matches however often it should actually run.

2

Ping inside the command's handle() method

Add the ping call after the command's real work succeeds, directly in the command class.

app/Console/Commands/SyncInventory.php
class SyncInventory extends Command
{
    protected $signature = 'app:sync-inventory';

    public function handle(): void
    {
        // ...existing command logic...

        Http::get('https://ping.pingtastic.net/ping/sync-inventory');
    }
}
3

Trigger it however you already do

A system crontab entry calling `php artisan app:sync-inventory`, a deploy hook, or a CI job — no scheduler changes needed, since the ping lives in the command itself.

Gotchas

  • ⚠If the command exits early via Command::FAILURE or throws before reaching the ping line, that's correct behavior — no ping means no success signal.
  • ⚠Unlike Schedule::command()->pingOnSuccess(), this pings regardless of whether Laravel's own scheduler is involved at all — useful when something outside Laravel entirely (CI/CD, a deploy script, direct cron) triggers the command.

Questions

Should I use this instead of pingOnSuccess()?

Use pingOnSuccess() when the command runs through Laravel's own Schedule::command() entries — see Monitor Laravel Scheduled Commands. Use this direct-ping approach when the command is triggered some other way.

Does this work for commands triggered by Schedule::call()?

Schedule::call() runs a closure rather than a command class, and pingOnSuccess() still works on that schedule entry too. This direct-in-command approach is for when you want the ping tied to the command's own code regardless of what triggers it.

Start monitoring your Laravel artisan commands

Set up your first monitor in under five minutes.

Get started — $5/month