How to Monitor Shell Script Cron Jobs with CronRabbit
Shell & BashThe Problem
Shell scripts in crontab fail silently — a missing file, permission denied, or syntax error produces no notification. You discover failures hours or days late.
The Solution
Append a curl command to your cron entry. CronRabbit expects the ping and alerts you if it doesn't arrive on time.
The One-Line Integration
Adding monitoring to a shell cron job is a single curl appended to your command. Use && to ensure the ping only fires on success, or use $? to report the exit code.
Recommended curl Flags
Use -fsS -m 10 --retry 5 --retry-all-errors for reliable pings. -f fails silently on HTTP errors, -s suppresses progress, -S shows errors, -m 10 sets a 10-second timeout, --retry 5 retries on failure, and --retry-all-errors ensures retries on connection timeouts.
Duration Tracking
Send /start before your main command and the success ping after. CronRabbit calculates the duration automatically.
Code Examples
Simple crontab with monitoring
Bash# Success-only ping
0 2 * * * /scripts/backup.sh && curl -fsS -m 10 --retry 5 --retry-all-errors https://ping.cronrabbit.com/your-id
# With exit code reporting
0 3 * * * /scripts/etl.sh; curl -fsS -m 10 --retry 5 --retry-all-errors https://ping.cronrabbit.com/your-id/$?With duration tracking
Bash#!/bin/bash
curl -fsS -m 5 --retry 3 --retry-all-errors https://ping.cronrabbit.com/your-id/start
/scripts/backup.sh
EXIT_CODE=$?
curl -fsS -m 10 --retry 5 --retry-all-errors https://ping.cronrabbit.com/your-id/$EXIT_CODE
exit $EXIT_CODE