Get a push notification when a cron job finishes
The nightly backup, the 3am data sync, the weekly report — they run in the dark and you find out they failed only when something downstream breaks. Lert puts a heartbeat on every scheduled job: one line in your crontab and your phone tells you it ran, or that it didn't.
Silent jobs are the dangerous ones
Cron's default behavior is to say nothing. A job that quietly stopped running three weeks ago looks exactly like one that's working — until the day you reach for the backup that was never made. The classic fix is to email yourself, but nobody reads cron email, and half the time the mailer isn't even configured on the box.
A push notification is different: it's on your phone, it's immediate, and it's impossible to ignore. You don't need it to fire every night — you need it to fire when the job finishes so you can trust the silence the rest of the time, or the moment it fails so you can act.
The one-line version
Lert gives you a unique URL. Anything that can make an HTTP request can POST to it. Add this to the end of the script your cron entry runs:
curl -X POST "https://lert.dev/p/your-id" \ -H "Content-Type: application/json" \ -d '{"title":"Nightly backup done","body":"db + uploads · 4.2 GB","tag":"cron"}'
The tag field is a free-form label — set it to cron or the job's name and every run shows up grouped in your in-app history. No auth token, no SDK. Replace your-id with your endpoint and you're done.
Set it up in three steps
1. Copy your Lert URL
Open the Lert app and copy your unique endpoint — something like https://lert.dev/p/your-id. Treat it like a password; anyone who has it can notify you, and you can regenerate it any time.
2. Wrap the job so it reports success or failure
The most useful pattern is to check the exit code and send different text for each outcome. Put this in a small wrapper script:
#!/usr/bin/env bash URL="https://lert.dev/p/your-id" if /usr/local/bin/run-backup.sh; then curl -X POST "$URL" -H "Content-Type: application/json" \ -d '{"title":"Backup ✅","body":"Completed at '"$(date +%H:%M)"'","tag":"backup"}' else curl -X POST "$URL" -H "Content-Type: application/json" \ -d '{"title":"Backup ❌ FAILED","body":"Exit code '"$?"' — needs you","tag":"backup"}' fi
3. Point cron at the wrapper
Add a single line to your crontab with crontab -e. This runs the backup every night at 3:00am; the notify calls are baked into the script it invokes:
# m h dom mon dow command 0 3 * * * /home/deploy/backup.sh
That's it. When cron fires the job, you get a real iOS push — it wakes a locked phone and buzzes a paired Apple Watch, usually within a second. Even at 3am on a headless server on the other side of the world.
More scheduled work to keep an eye on? The same pattern covers backup jobs, database alerts, and long-running scripts. For a full walkthrough see the cron guide, and if you'd rather send from a language, there's Python and Node.
Notify only when it matters
If a nightly job succeeds every night, a nightly success push gets tuned out fast. A common refinement is to stay quiet on success and only shout on failure using a || guard — that way a buzz always means "look now":
30 2 * * * /home/deploy/sync.sh || curl -X POST "https://lert.dev/p/your-id" \ --data-binary "Sync FAILED on $(hostname) at $(date +%H:%M)" \ -H "Content-Type: text/plain"
Why Lert for cron alerts
Cron notification usually means wrestling with sendmail, a monitoring SaaS, or a heartbeat service that needs its own account and dashboard. Lert is one HTTP request from a shell script — no daemon, no agent, no key. The endpoint URL is the authentication, so putting a heartbeat on every scheduled job is genuinely one line of work.
FAQ
How do I notify only when a cron job fails?
Check the exit code. Run your job, then send the POST only inside the failure branch of an if statement, or after a || operator. A healthy night stays silent; a broken one buzzes.
Does this work on a headless server with no GUI?
Yes. The notification is a plain HTTP request from the server to Lert — the push arrives on your phone, not the server. All the box needs is outbound network access.
Can I include the job's output in the notification?
Yes. Capture the output into a variable and send it as the body with text/plain. Keep it short — the body is capped at 2000 characters, which is plenty for a summary line.
Do I need an API key or account?
No. Your Lert endpoint URL is the authentication — there's no separate key, token, or login to wire up.
Related use cases
Give every scheduled job a heartbeat.
Download Lert, copy your URL, wrap your job in one curl. Your phone confirms it ran — or tells you it didn't.