Zum Inhalt springen

Cron job monitoring on your phone, for the job that fails and the job that never runs

Add one curl after a cron job. A failure buzzes your Android phone with the end of its output, a success stays silent, and a run that never happens alerts you too.

Free to start, no ads. Android 7 and up.

One line in your crontab

Send the job's exit status

Make a channel in the app and copy its address. Then end the job's line with a POST to that address plus $?, the status the job exited with. 0 is a silent heartbeat: no notification. Any other status is a high-priority alert, "Exited with status N", with the end of the output as its text. A job that keeps failing alerts you at most once a clock hour for each status, not on every run.

# crontab -e
ANYPUSH_URL=https://anypush.app/h/your-token

# every 15 minutes; the last 20 lines of output go along if it fails
*/15 * * * * /usr/local/bin/sync.sh > /tmp/sync.log 2>&1; tail -n 20 /tmp/sync.log | curl -fsS -m 10 --retry 3 --data-binary @- "$ANYPUSH_URL/$?"

exit 0 → {"heartbeat":true} · exit 23 → {"duplicate":false,"id":743}

# /etc/systemd/system/sync.service, started by sync.timer
[Service]
Type=oneshot
ExecStart=/usr/local/bin/sync.sh
# runs after the job, whether it worked or not
ExecStopPost=/bin/sh -c 'if [ "$SERVICE_RESULT" = success ]; then s=0; else s=1; fi; curl -fsS -m 10 --retry 3 -X POST "https://anypush.app/h/your-token/$s"'

success → {"heartbeat":true} · failure → {"duplicate":false,"id":745}

#!/bin/sh
out=$(/usr/local/bin/sync.sh 2>&1)
status=$?
printf '%s\n' "$out" | tail -n 20 | curl -fsS -m 10 --retry 3 --data-binary @- "$ANYPUSH_URL/$status"
exit $status

The address is a secret: anyone who has it can send to your phone. Keep it in the crontab or an environment file that only you can read.

Tested on 26 November 2026

On 26 November 2026 the crontab line ran against a live channel under bash (Fedora's /bin/sh) and under dash (Debian's /bin/sh); in both, $? at the end of the line is the job's status. A job that exited 0 answered {"heartbeat":true} and sent no notification. Jobs that exited 23 and 5 arrived as high-priority "Exited with status 23" and "Exited with status 5", with the job's last lines as the text. The systemd unit ran under systemd 262 exactly as written above: a run that succeeded sent a heartbeat, and a run that failed arrived as "Exited with status 1". The silence alert was tested on a channel given 1 hour: one high-priority alert came 60 minutes after the setting was saved, the next heartbeat answered {"heartbeat":true,"id":779} and sent one "Heard from again", and the heartbeat after that was silent again.

Why not cron's own mail?

cron mails a job's output to MAILTO, which needs a mail server on the machine that can deliver to you (crontab(5)). It mails on any output, not on failure, so a noisy job fills your inbox and a silent failure sends nothing. And a job that never runs sends no mail at all. The exit status says what happened, and the silence alert covers what did not.

Other ways

If you already run a monitoring service with a dashboard, such as Healthchecks.io or Cronitor, keep it, and point its alerts at your phone in the way it offers. anypush is for when you want the alert itself on your Android phone, with the job's output in it, and nothing else to run. It has no iPhone app and cannot be self-hosted. How anypush compares.

Questions

Will a job that fails every few minutes flood my phone?

No. The same exit status alerts at most once per clock hour. A different status, say 1 and then 2, alerts again, because it is a different failure.

Does a heartbeat count as a message?

No. A heartbeat (status 0) is not kept in your inbox and makes no notification. It moves the channel's last-seen time and starts the silence clock again. It does count towards the 60 requests a minute a channel takes.

Why POST, and not a plain GET?

Chat apps and link previews open addresses with GET. If a GET counted as a heartbeat, pasting the address into a chat could hide a dead job. anypush only takes a POST.

What if curl itself cannot reach anypush?

--retry 3 tries again on a network error. If the machine is offline for longer, the silence alert fires: that is the case it is for.

Should this be my only monitoring?

For anything critical, no. Alerts are best effort, and a phone can delay or silence them. Use anypush beside your other monitoring, not instead of it.

Get anypush

Free to start, no ads. Android 7 and up.