Get notified when a cron job or backup finishes or fails
Updated October 17, 2026
Add a curl call after the job, or wrap the job in a small script that reports the result. NextMsg delivers it as a push to your phone within seconds, including the exit code and the end of the output when something fails.
The one-liner
Install the NextMsg app and copy your send key from Settings. Then send a message after the job succeeds:
# crontab -e
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -d 'Nightly backup finished' "https://api.nextmsg.app/p/nextmsg_live_YOUR_KEY?channel=backups"Change && to || to be told only when it fails.
A wrapper for success and failure
Save this as /usr/local/bin/notify-run and make it executable (chmod +x):
#!/bin/sh
# Runs a command and sends the result to your phone.
# Usage: notify-run NAME COMMAND [ARGS...]
name="$1"; shift
output=$("$@" 2>&1)
code=$?
url="https://api.nextmsg.app/p/$NEXTMSG_KEY?channel=cron"
if [ "$code" -eq 0 ]; then
curl -fsS --data-binary "✅ $name finished" "$url" >/dev/null
else
tail=$(printf '%s' "$output" | tail -n 5 | cut -c1-120)
curl -fsS --data-binary "❌ $name failed (exit $code)
$tail" "$url" >/dev/null
fi
exit "$code"Then use it in your crontab. Most cron implementations let you set the key once at the top:
NEXTMSG_KEY=nextmsg_live_YOUR_KEY
0 3 * * * /usr/local/bin/notify-run "Nightly backup" /usr/local/bin/backup.sh
*/30 * * * * /usr/local/bin/notify-run "Price check" python3 /opt/jobs/prices.pyA message holds up to 640 characters, so the wrapper sends only the last five lines of output. The script keeps the job's exit code, so cron's own error handling still works.
Tips
- Separate channels: use
?channel=backups,?channel=jobsand so on to give each kind of job its own tab in the app. - Only failures for frequent jobs: a job that runs every few minutes should report failures only, or you will mute it.
- Protect the key: anyone with it can send to your inbox (but not read it). Keep the crontab readable only by its user, and rotate the key in the app if it leaks.
- systemd timers: use
OnFailure=, shown in the server alerts guide.
What this can't catch
If cron itself stops or the server is down, the job never runs and nothing is sent. To be alerted about jobs that didn't run, use a dead man's switch service such as Healthchecks.io and point its webhook integration at your NextMsg quick URL.
More guides
- Get a phone notification when a GitHub Action fails
- Server alerts to your phone without Telegram or Slack
- AWS alerts to your phone: CloudWatch alarms and EventBridge events
- Make Claude Code, Cursor or any AI agent ping your phone
- Get a phone notification when Cursor's agent finishes
- Get a phone notification when OpenAI Codex finishes a task
- Phone notifications from Google Antigravity and Gemini agents