cronping

Monitoring Cron Jobs

How to configure your cron jobs to report to Cronping.

The Pattern

The simplest and most reliable way to monitor a cron job is to append a curl call after the main command. The ping only fires on success because && requires the previous command to exit with code 0.

# ✅ Only pings if backup.sh succeeds
0 3 * * * /usr/bin/backup.sh && curl -fsS https://ping.cronping.com/<token>

The -fsS flags make curl fail silently on HTTP errors (-f), suppress progress output (-s), but still show errors if something goes wrong (-S).


Suppressing output

Cron sends an email for any command that produces output. To suppress that, redirect both stdout and stderr:

0 3 * * * /usr/bin/backup.sh >> /var/log/backup.log 2>&1 && curl -fsS https://ping.cronping.com/<token> > /dev/null

Wrapping a command with &&

If your job is a chain of commands and only the last one produces exit code 0, wrap everything in a subshell:

5 4 * * * ( /usr/bin/step1.sh && /usr/bin/step2.sh ) && curl -fsS https://ping.cronping.com/<token>

Full example crontab

# Daily database backup at 3:00 AM
0 3 * * * /usr/local/bin/backup-db.sh && curl -fsS https://ping.cronping.com/TOKEN1

# Hourly queue worker health check
0 * * * * /usr/local/bin/check-queue.sh && curl -fsS https://ping.cronping.com/TOKEN2

# Weekly report generation — Mondays at 8 AM
0 8 * * 1 /usr/local/bin/generate-report.sh && curl -fsS https://ping.cronping.com/TOKEN3

Cron syntax reference

┌───────────────── minute (0–59)
│ ┌─────────────── hour (0–23)
│ │ ┌───────────── day of month (1–31)
│ │ │ ┌─────────── month (1–12)
│ │ │ │ ┌───────── day of week (0–7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *
ExpressionMeaning
* * * * *Every minute
0 * * * *Every hour (at :00)
0 3 * * *Every day at 3:00 AM
0 9 * * 1-5Weekdays at 9:00 AM
0 8 * * 1Every Monday at 8:00 AM
*/15 * * * *Every 15 minutes
0 0 1 * *First day of every month at midnight
0 0 1 1 *January 1st at midnight (yearly)

Windows Task Scheduler

On Windows, use PowerShell to make the ping request:

# Run your script, then ping Cronping on success
your-script.ps1
if ($LASTEXITCODE -eq 0) {
    Invoke-RestMethod -Uri "https://ping.cronping.com/<token>" -Method Get
}

Or create a wrapper .bat file:

REM Run job script
call C:\Scripts\backup.bat

REM Check exit code and ping Cronping on success
IF %ERRORLEVEL% EQU 0 (
    curl -fsS https://ping.cronping.com/<token>
)

Reliability tips

  • Use && (not ;)&& only pings on success. ; would ping even if the job failed.
  • Set a timeout on curl — prevents curl from hanging indefinitely: curl -fsS --max-time 10 https://...
  • Choose a generous grace time — if your job normally takes 2 minutes but occasionally 8, set grace time to at least 10 minutes.
  • Match the timezone — when using cron expressions, always set the timezone to match your server's local time to avoid issues with DST.
  • Test it — after adding the ping, manually run the command and verify the heartbeat transitions to Up in the dashboard.

Already have many cron jobs?

If you have an existing crontab with dozens of entries, or Kubernetes CronJob manifests, you can import them all at once with Bulk Import instead of creating each heartbeat manually.

On this page