Why silent cron failures are the expensive ones: heartbeat monitoring and an online DST check
A nightly backup reported success for three weeks. Cron never started it: no error, no log line, exit code 0.
This article separates the two questions that such incidents hide - did it run today? (PulseWatch) and will it run at all? (CronPulse) - with copy-paste curl calls, state-machine output, and a live online checker. Every command and exit code below was run locally or against https://hook.kogasa.xyz.
1. The expensive failure is not an error - it is absence
Most monitoring watches for failure: a non-zero exit, an ERROR line, an HTTP 500. Scheduled jobs have a quieter failure mode:
- the cron daemon was never started, or the crontab disappeared after a container rebuild;
- the expression is
0 2 30 2 *- February 30th, which never fires; - after a migration to systemd the unit was renamed, and the old
.timeris no longer loaded; - a spring DST gap makes 02:30 on 2026-03-08 nonexistent, and the daemon silently skips it;
- the job actually runs on another host or under another account.
In all of these cases the job did not fail. It did not exist. Logs are empty, the exit code is 0, alerts are quiet, and the downstream report is simply missing a day. You usually find out during reconciliation or an audit.
That calls for two opposite checks:
| Question | Tool | How it decides |
|---|---|---|
| Did it run today? | PulseWatch heartbeat | The job pings on success; no ping within period + grace raises one alert |
| Will it run at all? | CronPulse schedule check | Parses the expression, previews real instants, flags DST gaps/overlaps and never-firing dates |
The first is a dead man's switch: no news is bad news. The second answers "does this schedule actually exist?" before deployment. Neither needs an agent installed, and neither requires opening a public port on your host.
2. The 60-second setup
Live instance: https://hook.kogasa.xyz (3 free monitors, no credit card). Enter an email in the console to mint a workspace key, then create a monitor.
curl -fsS -m 10 https://hook.kogasa.xyz/healthz
{ "ok" : true, "version" : "0.2.1" , "uptime_s" : 11956 }
A monitor named nightly-backup-demo (period 86400 s, grace 300 s) gives you three things: a ping URL https://hook.kogasa.xyz/ping/<token>; a curl line you can paste at the end of a crontab entry; an SVG status badge at /badge/<token>.svg.
On success the job only needs one GET:
# Last line of the backup script; never reached when the job fails
curl -fsS -m 10 --retry 3 \
"https://hook.kogasa.xyz/ping/<token>" > /dev/null
Real response from the demo monitor:
curl -sS -m 10 "https://hook.kogasa.xyz/ping/<token>" -w '\nHTTP %{http_code}\n'
{ "ok" : true, "status" : "up" , "recovered" : false }
HTTP 200
Three deliberate choices:
- Success only. Use
set -euo pipefail, or place the curl after&&. A failed run exits before reporting. The heartbeat means "the business step completed", not "the process started". - The ping token is a write credential. Anyone holding the ping URL can keep the monitor green. Keep it in the crontab or a secret store, not in a public repository. The badge URL is safe to publish: it is read-only.
- No guessing. An unknown token returns 404 and never creates an implicit monitor:
curl -sS -m 10 "https://hook.kogasa.xyz/ping/does-not-exist"
{ "ok" : false, "error" : "unknown monitor token" }
3. State machine: one down alert, one recovery alert
The classic heartbeat mistake is alerting on every check. A single outage produces hundreds of messages, the channel gets muted, and the next real outage is invisible.
PulseWatch collapses this into two events:
ping now > periodnow > period + grace new โโโโโโโโโโบ up โโโโโโโโโโบ late โโโโโโโโโโโโโโโโโโบ down (one alert)
โฒโ โpingโ โโโโโโโโโโโโโ recovered (one notice) โโโโโ
The output below comes from the repository's HeartbeatEngine, with time injected so the run is exactly reproducible (period 60 s, grace 30 s):
from pulsewatch.db import Store
from pulsewatch.engine import HeartbeatEngine
from pulsewatch import notifiers
store = Store ( ":memory:" )
user = store.create_user ( "o****@example.com" )
engine = HeartbeatEngine ( store, base_url = "https://hook.kogasa.xyz" )
t0 = 1_800_000_000
m = engine.create_monitor ( user [ "id" ] , "nightly-backup" , 60, 30, now = t0 )
engine.ping ( m [ "token" ] , now = t0 )
for offset in ( 61, 92, 120 ) :
events = engine.check ( now = t0 + offset )
print ( f "t+{offset:<3} check ->" , [ ( e.kind, e.name ) for e in events ] or "no new alert" )
for e in events:
notifiers.dispatch ( store, e, [ notifiers.LogNotifier ( ) ] )
ev = engine.ping ( m [ "token" ] , now = t0 + 200 ) [ "event" ]
print ( "t+200 ping->" , ( ev.kind, ev.name ) if ev else "up" )
if ev:
notifiers.dispatch ( store, ev, [ notifiers.LogNotifier ( ) ] )
print ( "alerts stored:" , [ ( a [ "kind" ] , a [ "channel" ] , a [ "ok" ] ) for a in store.list_recent_alerts_for_user ( user [ "id" ] ) ] )
created: new period = 60s grace = 30s
t+0 ping- > up
t+61check - > no new alert
t+92check - > [ ( 'down' , 'nightly-backup' ) ]
WARNING ๐ด ๅฟ่ทณไธขๅคฑ๏ผnightly-backup ้ๅผ๏ผ60s ๅจๆ + 30s ๅฎฝ้ ๆๅไธๆฅ๏ผ2027-01-15 08:00:00 UTC ๅทฒๆ็ปญ๏ผ1 ๅ้ ๆขๅคๅไผ่ชๅจๅ้ๆขๅค้็ฅใ
t+120 check - > no new alert
t+200 ping- > ( 'recovered' , 'nightly-backup' )
WARNING ๐ข ๅฟ่ทณๆขๅค๏ผnightly-backup ๆขๅคๆถ้ด๏ผ2027-01-15 08:03:20 UTC ๅๆบๆถ้ฟ๏ผ็บฆ 1 ๅ้
alerts stored: [ ( 'recovered' , 'log' , 1 ) , ( 'down' , 'log' , 1 ) ]
(The log adapter is localized in Chinese; the events and timestamps are what matter here.)
Key details: t+61 is only "late" - no alert. t+92 exceeds 60 + 30, so it becomes down. The next check at t+120 produces no second down. The recovery ping emits exactly one recovered, with the outage duration. A monitor that never reported is measured from its creation time, so "created but never wired up" cannot stay silent forever.
Alert channels are Feishu, WeCom, DingTalk (including signed requests) and email. Webhook targets are stored masked as scheme://host/***, and delivery failures are persisted in an alerts table instead of raising. All of this is available on the free plan - being woken up should not be the paid feature.
4. DST: a valid expression, exit code 0, and the job still does not run
A heartbeat proves the job is missing. To explain why, look at the schedule. The classic case is the US Eastern spring transition on 2026-03-08: 02:00 jumps to 03:00, so 02:30 does not exist.
pip install cronpulse-cli
cronpulse next "30 2 * * *" --tz America/New_York --after 2026-03-07T12:00 -n 2
30 2 * * * ( after 2026-03-07T12:00:00-05:00 )
1. 2026-03-09 02:30:00-04:00
2. 2026-03-10 02:30:00-04:00
note: skipped 1 wall-clock time ( s ) that do not exist ( DST gap ) : 2026-03-08 02:30:00
echo $?
0
The exit code is still 0, because the expression is valid and fires on other days. This class of bug never appears as "the command failed"; it only appears in the note: line and in the JSON field dst.skipped. Feed that into a daily check, and you find it before the downstream report is empty.
Autumn is the mirror image. On 2026-11-01, 01:00 and 01:30 each happen twice, so the same cron runs twice:
cronpulse next "*/30 1 * * *" --tz America/New_York --after 2026-10-31T23:30 -n 4
*/30 1 * * * ( after 2026-10-31T23:30:00-04:00 )
1. 2026-11-01 01:00:00-04:00
2. 2026-11-01 01:30:00-04:00
3. 2026-11-01 01:00:00-05:00
4. 2026-11-01 01:30:00-05:00
note: 2 wall-clock time ( s ) occur twice ( DST overlap ) , both listed: 2026-11-01 01:00:00, 2026-11-01 01:30:00
The two offsets -04:00 and -05:00 are proof of two real runs. Idempotency keys must be based on UTC timestamps, never on a local 01:00. For backups, invoicing, and coupon issuance, the autumn duplicate is usually more dangerous than the spring skip.
Online check, no login
If you do not want to install the CLI, the "Free Cron / systemd check" tab on PulseWatch is powered by the same CronPulse engine. It also has a JSON endpoint:
curl -sS -m 10 -X POST https://hook.kogasa.xyz/api/cron-check \
-H 'Content-Type: application/json' \
-d '{"expr":"Mon..Fri 09:00","kind":"systemd","tz":"Asia/Shanghai","count":2}'
{ "ok" : true, "kind" : "systemd" , "expr" : "Mon..Fri 09:00" , "timezone" : "Asia/Shanghai" , "explanation" : "systemd OnCalendar: Mon..Fri 09:00" , "fires" : true, "check_note" : "" , "runs" : [ "2026-12-02T09:00:00+08:00" , "2026-12-03T09:00:00+08:00" ] , "dst_warnings" : [ ] }
Cron expressions use the same shape:
curl -sS -m 10 -X POST https://hook.kogasa.xyz/api/cron-check \
-H 'Content-Type: application/json' \
-d '{"expr":"30 2 * * *","tz":"America/New_York","count":2}'
{ "ok" : true, "kind" : "cron" , "expr" : "30 2 * * *" , "timezone" : "America/New_York" , "explanation" : "minute=30; hour=2; day-of-month=*; month=*; day-of-week=*" , "fires" : true, "check_note" : "" , "runs" : [ "2026-12-02T02:30:00-05:00" , "2026-12-03T02:30:00-05:00" ] , "dst_warnings" : [ ] }
dst_warnings covers the forward window; it is empty when no transition is inside that window. To reproduce a past incident, use the local CLI with --after; the online page is for pre-deployment and routine checks. It also rejects never-firing dates and Quartz-only syntax (15W, L, #) instead of returning a plausible approximation.
5. Put the status badge in your README
The live badge is read-only and safe to embed:
[](https://hook.kogasa.xyz)
The demo monitor currently returns:
curl -sS -m 10 "https://hook.kogasa.xyz/badge/<token>.svg" \
-o badge.svg -w 'HTTP %{http_code} %{content_type} %{size_download}\n'
HTTP 200 image/svg+xml ; charset = utf-8 477
head -c 120 badge.svg
< svg xmlns = "http://www.w3.org/2000/svg" width = "205" height = "20" role = "img" aria-label= "nightly-backup-demo: UP" > ...
The badge state comes from the same state machine (up / late / down / paused); no extra refresher job is involved. Public badge does not mean public ping URL: the badge is read-only, the ping URL is a write credential.
6. Seven operating rules before you rely on it
- Report at the end of the success path, not at the start. A ping at the start only proves an attempt.
- Leave real headroom. A daily backup with 24 h + 0 grace will page you the first time it runs five minutes long. Set period = schedule interval and grace = longest normal runtime + network jitter.
- Use a channel that wakes someone. At least one group bot; a log-only setup is not an alert.
- Rehearse. Pause a job once and confirm both down and recovered arrive.
- Make DST-sensitive jobs UTC-idempotent. Reconciliation, billing, and coupon issuance should use UTC timestamps as the unique key.
- Monitor the monitor. PulseWatch is a single point of failure. Give the alert channel a second human, or watch
/healthzfrom an external uptime check. - Review schedule changes like code.
cronpulse driftcan diff the live crontab against an inventory, so "who changed the time" has an answer.
7. Free and Pro Plan Price
What you get:
- Free 0 CNY: Unlimited online Cron/systemd + DST checks, 3 heartbeat monitors, Feishu/WeCom/DingTalk alerts, SVG badge
- Pro 9.9 CNY/month ยท 49 CNY/year: 50 monitors, offline signed license (self-hosting supported), LeakPulse + CronPulse CI templates, priority support
The core engine is MIT and uses only the Python standard library, so you can self-host it offline. Pro sells capacity and delivery support, not the alerting itself. Licenses are pw1. HMAC tokens; the server stores only a fingerprint, never the signing secret.
Get Pro via Afdian https://afdian.com/a/stackpulse-lab or a GitHub issue https://github.com/stackpulse-lab/stackpulse-lab/issues. If your team also needs a one-off audit (secret leaks, crontab/timer drift, port baseline), the delivery kit's quickcheck.py produces a redacted report: https://github.com/stackpulse-lab/stackpulse-lab/tree/main/offers/ci-secrets-cron-health.
8. Reproduction checklist
# 1. Online check, no login
curl -fsS https://hook.kogasa.xyz/healthz
# 2. Reproduce the DST gap and overlap locally
pip install cronpulse-cli
cronpulse next "30 2 * * *" --tz America/New_York --after 2026-03-07T12:00 -n 2
cronpulse next "*/30 1 * * *" --tz America/New_York --after 2026-10-31T23:30 -n 4
# 3. Heartbeat state-machine tests (source repo)
git clone https://github.com/stackpulse-lab/pulsewatch
cd pulsewatch && python3 run_tests.py
On this machine python3 run_tests.py prints Ran 59 tests ... OK, covering license tampering/expiry, the free-3 / Pro-50 quotas, alert de-duplication, recovery duration, and webhook masking.
One sentence: add a heartbeat to everything that is supposed to happen regularly, and run a DST check on every schedule. The first turns silence into an alert; the second exposes "valid but nonexistent" instants before deployment.
Live: https://hook.kogasa.xyz ยท Source: https://github.com/stackpulse-lab/pulsewatch
Comments
No comments yet. Start the discussion.