Monitor PHP Cron Scripts

Learn how to monitor PHP scheduled tasks and cron scripts with Haspulse.

Features

  • Works with vanilla PHP and frameworks
  • cURL and file_get_contents support
  • WordPress wp-cron integration
  • Composer package available

Code Examples

Basic PHP
<?php
$checkUrl = 'https://haspulse.io/ping/' . getenv('CHECK_ID');

// Signal start
file_get_contents($checkUrl . '/start');

try {
    // Your job logic
    processData();

    // Signal success
    file_get_contents($checkUrl);
} catch (Exception $e) {
    // Signal failure
    file_get_contents($checkUrl . '/fail');
    throw $e;
}
With cURL
<?php
function pingHaspulse(string $checkId, string $status = ''): void {
    $url = "https://haspulse.io/ping/{$checkId}";
    if ($status) {
        $url .= "/{$status}";
    }

    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_FOLLOWLOCATION => true,
    ]);
    curl_exec($ch);
    curl_close($ch);
}

// Usage
pingHaspulse('YOUR_CHECK_ID', 'start');
// ... run job ...
pingHaspulse('YOUR_CHECK_ID');

How It Works

  1. 1
    Create a check in Haspulse
    Set your expected schedule (e.g., every 5 minutes)
  2. 2
    Add the ping to your code
    Ping the unique URL when your job runs successfully
  3. 3
    Get alerted on failures
    If a ping doesn't arrive on time, we notify you

Related Integrations

Start monitoring in minutes

Create your first check and start receiving alerts when your scheduled jobs fail.

Get started free