Reliability & Infrastructure

    Heartbeat Monitoring for Cron Jobs & Scheduled Tasks

    Ensure your cron jobs, background workers, and scheduled tasks run on time — get alerted the moment a job goes silent.

    8 min readGuide

    Why Traditional Monitoring Can't Watch Cron Jobs

    HTTP monitors poll your servers from the outside, but cron jobs, queue workers, and scheduled tasks run inside your infrastructure with no public endpoint. If a nightly billing reconciliation silently stops running, an HTTP check will never notice. Heartbeat monitoring flips the model: your job pings FourSight when it completes, and FourSight alerts you when the ping doesn't arrive on time.

    💡 According to incident post-mortems, over 40% of silent SaaS outages originate from background jobs that stopped running without anyone noticing for hours — or days.

    How Heartbeat Monitoring Works

    When you create a heartbeat monitor in FourSight you receive a unique ping URL. Your job sends a simple HTTP request to that URL every time it completes successfully. FourSight tracks the expected interval and a configurable grace period. If a ping doesn't arrive before the deadline, FourSight opens an incident and notifies your team through your configured escalation policy.

    Fixed-Interval Mode

    Set an expected interval (e.g. every 5 minutes, every hour) and a grace window. This is ideal for jobs that run on simple repeating schedules like queue consumers, health-check scripts, or data-sync workers.

    Cron-Expression Mode

    Provide a standard 5-field cron expression (e.g. '30 2 * * *' for 2:30 AM daily). FourSight calculates the next expected run time dynamically, making it perfect for jobs with complex schedules like 'every weekday at 9 AM' or 'first Sunday of the month'.

    Grace Period & Miss Threshold

    The grace period absorbs normal jitter — a job that's 20 seconds late on a 5-minute schedule shouldn't wake anyone up. The miss threshold lets you require multiple consecutive missed pings before alerting, reducing noise from transient issues.

    Monitoring a Commercial SaaS?

    FourSight includes 25 commercial-safe monitors with multi-region validation.

    Start Monitoring Free

    Setting Up Your First Heartbeat Monitor

    In the FourSight dashboard, create a new monitor and select the Heartbeat type. Choose your schedule mode, set your interval or cron expression, and configure a sensible grace period. FourSight generates a unique ping URL you'll add to the end of your job.

    # At the end of your cron job script:
    curl -fsS --retry 3 https://ping.foursight.cloud/hb/<YOUR_TOKEN>
    
    # Example crontab entry — daily DB backup at 3 AM
    0 3 * * * /opt/scripts/backup-db.sh && curl -fsS --retry 3 https://ping.foursight.cloud/hb/<YOUR_TOKEN>

    Common Use Cases

    Heartbeat monitoring is useful anywhere a process should run on a predictable schedule.

    Database Backups

    Append a ping to your pg_dump or mysqldump script. If tonight's backup doesn't complete, you'll know by morning — not during the next disaster recovery drill.

    Queue Workers & Consumers

    Have your worker ping FourSight on each processing cycle. If the worker crashes or the queue stalls, the missed heartbeat triggers an alert before messages pile up.

    Billing & Invoice Generation

    Scheduled billing runs are revenue-critical. A missed invoice cycle can cascade into payment failures and churn. Heartbeat monitoring catches the silence.

    Data Sync & ETL

    Nightly data imports, warehouse refreshes, and third-party API syncs all benefit from heartbeat checks that confirm successful completion.

    Best Practices

    Place the ping call after your job's success criteria, not at the start. Use --retry flags on curl to survive transient network blips. Set your grace period to at least 20% of the interval to absorb normal execution-time variance. Pair heartbeat monitors with an escalation policy so the right person is paged — not just an email that sits unread.

    Protect Your SaaS Revenue

    Start monitoring in under 60 seconds.