Heartbeats

Monitor the execution of your cronjobs, backups, and scheduled scripts. Automatic alerts via Telegram, Discord, or Email if anything fails.

What is a heartbeat?

A heartbeat is an HTTP signal that your script sends to SecuryBlack when it finishes. If that signal doesn't arrive within the configured interval, you receive an immediate alert.

It's ideal for monitoring:

  • Scheduled backups
  • Critical cronjobs
  • Maintenance scripts
  • Batch jobs
  • Asynchronous tasks

How it works

  1. 1

    Create a heartbeat in SecuryBlack

    Define the name, interval (cron expression), and actions on failure

  2. 2

    Receive a unique URL

    Something like: https://api.securyblack.com/heartbeats/ping/YOUR_PING_KEY

  3. 3

    Your script calls it when done

    Add a curl line at the end of your script: curl https://api.securyblack.com/heartbeats/ping/YOUR_PING_KEY

  4. 4

    SecuryBlack verifies the ping arrives on time

    If it doesn't arrive within the configured interval, it sends an alert

Create a heartbeat

  1. 1

    Go to the Heartbeats section

    In your dashboard, look for "Heartbeats"

  2. 2

    Click "New Heartbeat"

    Enter a descriptive name

  3. 3

    Configure the interval

    Using cron expressions or presets (every hour, every day, etc.)

  4. 4

    Configure alerts

    Email, Discord, Telegram, Slack, etc.

  5. 5

    Copy the URL

    Use it in your script

Cron Expressions

Configure when you expect your script to run using standard cron expressions (UTC):

0 2 * * *
Every day at 2:00 AM UTC
0 */6 * * *
Every 6 hours
0 0 * * 0
Every Sunday at 00:00 UTC

Use crontab.guru to generate your cron expressions.

Usage examples

Daily backup

Bash script that runs a backup and notifies SecuryBlack:

#!/bin/bash
# Backup script

# Your backup logic here
mysqldump -u root -p mydb > /backups/mydb.sql

# Notify SecuryBlack that the backup completed
curl -s https://api.securyblack.com/heartbeats/ping/YOUR_PING_KEY

echo "Backup completed"

Python script with error handling

import subprocess
import requests

try:
    # Your logic here
    result = subprocess.run(['python', 'sync_data.py'], check=True)

    # Only notify if everything went well
    requests.get('https://api.securyblack.com/heartbeats/ping/YOUR_PING_KEY')

except Exception as e:
    print(f"Error: {e}")
    # Don't send ping if there's an error
    # SecuryBlack will detect the missing heartbeat

Advanced options

Grace period
Additional time after the expected interval before sending an alert. Useful for scripts that occasionally run late.
90-day history
View all heartbeats received in the last 90 days to detect failure patterns.
Rotate ping_key
Regenerate the heartbeat URL if you believe it has been compromised.

Best practices

  • Use heartbeats for critical cronjobs (backups, synchronizations, etc.)
  • Place the curl at the END of the script, only if everything went well
  • Use precise cron expressions that reflect when you actually expect it to run
  • Review history regularly to detect anomalies
  • Don't use heartbeats for 24/7 services — use uptime monitoring for that