Crontab Cron Job Monitoring

The crontab (cron table) is the grandfather of all task schedulers. It is present on almost every Unix-like system. While it is incredibly reliable at starting tasks, it has no built-in way to tell you if a task failed or took too long.

olic.io bridges that gap. By appending a simple command to your existing cron entry, you can turn a silent Linux utility into a monitored, alert-ready system.

Adding a Heartbeat to Your Crontab

You don’t need to modify the script you are running. You can simply chain a curl command using the && (AND) operator. This ensures the ping only happens if the first command succeeds (exit code 0).

Implementation

Open your crontab: crontab -e

Add the ping to your schedule:

# Run backup.sh at 3am. If successful, ping olic.io
0 3 * * * /home/user/scripts/backup.sh && curl -fsS -m 10 --retry 5 https://api.olic.io/ping/YOUR-ID-HERE > /dev/null

Breakdown:

  • &&: Only runs the ping if backup.sh succeeds.
  • -fsS: Fail silently (don’t clutter logs) but show errors if they happen.
  • -m 10: Max time 10 seconds (don’t hang the cron).
  • --retry 5: Retry 5 times if the network blips.

Why Use Crontab Directly

Direct Crontab usage is the backbone of Indie Hackers and sysadmins who value simplicity over complex orchestration tools like Kubernetes. It is perfect for Scheduling tasks like log rotation or certificate renewal.

The downside is visibility. A syntax error in a script can cause a cron job to fail silently for weeks. By adding the olic.io ping, you get Real time notifications (via Slack, Email, etc.) the moment a schedule is missed.

Learn more about Crontab here.

Need help?