Know when a Kubernetes CronJob didn’t run.
A CronJob that can’t pull its image, is evicted or stays suspended leaves no trace you’d notice. Ping Runbell from the container and get an alert when a run is missing.
Up
report
- Schedule
0 */6 * * *every 6 hours- Grace period
- 30 minutes
- Alerts
- Slack and PagerDuty
What goes wrong without anyone noticing
- The image can’t be pulled
- A tag is deleted or the registry credentials expire, and pods never start.
- Runs are skipped
concurrencyPolicyandstartingDeadlineSecondsquietly skip runs after a missed window.- The cluster is moved
- The manifest isn’t applied in the new cluster, so the job doesn’t exist there at all.
Set it up
-
Create a check
Use the schedule
0 */6 * * *and a grace period of 30 minutes, in the time zone the job runs in. -
Add the ping
Run the job and the ping in the same shell command, and send the job’s exit code.
-
Choose who hears about it
Connect email, Slack, Telegram, SMS or any of the other channels to the project.
report-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: report
spec:
schedule: "0 */6 * * *"
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
containers:
- name: report
image: registry.example.com/report:1.4
command: ["/bin/sh", "-c"]
args:
- /app/report; curl -fsS -m 10 --retry 5 https://runbell.app/ping/your-check-id/$?
Tips
- Use one check per CronJob, with the same schedule.
- Create checks from your deploy pipeline with the API, so every new CronJob is watched from day one.
- Set the check’s time zone to the CronJob’s
timeZone, or UTC.
Questions
Our images don’t have curl. What then?
Use wget, or a few lines in the job’s own language: any HTTP request works.
Can I see how long each run takes?
Yes. Ping /start at the beginning and the result at the end, and Runbell shows the run time.
Other jobs to watch
- pg_dump, mysqldump Database backups Know the night a backup fails, not the day you need it.
- crontab Linux cron jobs An alert when a crontab job is late, missing or fails.
- PowerShell Windows Task Scheduler Know when a scheduled task didn’t run or failed.
- ETL, Airflow, reports ETL and reports Hear about the pipeline that didn’t finish before the morning meeting.
- certbot, ACME Certificate renewal Find out before an expired certificate does.