Jamie Woods
Jamie Woods

Reputation: 579

Ensuring that laravel scheduled cron jobs have run in production

I have a scheduled cron job that runs laravel's task scheduler in a laravel forge production server. This cron job is ran every minute to ensure that any jobs that have been scheduled in the scheduler is ran. The task scheduler has multiple jobs that all execute at different times.

Essentially what I want is a way to monitor the cron job in production so that if it fails or isn't running I'm notified via an alert e.g. slack, sms. Without any alert I wouldn't be able to know if the cron job isn't running without manually checking. What's the best way of achieving this? Thanks.

Upvotes: 0

Views: 906

Answers (1)

Ahmad H.
Ahmad H.

Reputation: 370

If I get you right, you may take advantage of Pinging URLs to ping a specific url after your cron job is run. Something like following:

$schedule->command('emails:send')
         ->daily()
         ->thenPing($url);

Now you can either build your endpoint ($url) to make sure that it has been hit daily or use any of many free/paid cron monitoring services.

Upvotes: 1

Related Questions