Cron Job Monitoring for PHP applications

Cron job monitoring in your PHP code #

Oh Dear users can add cron job monitoring to any existing PHP script. When you create a cronjob monitor in your account, you're given a unique pingback URL that should be called every time a script completes.

In this guide, we'll cover how you can implement that in your existing PHP code.

Cron monitoring in generic PHP #

This is a technique that can be used in any PHP application, regardless of the framework you use.

At the very bottom of your scheduled command, add a call to the file_get_contents() function that will call back to us and inform you the job has ended.


Note: make sure your script stops executing on error conditions, so the file_get_contents() function isn't called even if the script has failed.

Cron monitoring in Laravel (PHP) #

Note: there's a convenient Laravel package called spatie/laravel-schedule-monitor you can use that syncs up nicely with Oh Dear. Please refer to this package's documentation on how it works.

In standard Laravel, you can use the thenPing() method in your Console scheduler. You'll find this in the app/Console/Kernel.php file.

class Kernel extends ConsoleKernel
    protected function schedule(Schedule $schedule)

Was this page helpful to you? Feel free to reach out via or on Twitter via @OhDearApp if you have any other questions. We'd love to help!