Cron alerts

Cron job failure alerts to your phone.

Turn boring shell failures into encrypted phone alerts without exposing history or command execution.

Simple shell integration

Nerve fits cron because it accepts stdin. Pipe a failure line into nerve send and keep the sender DSN in the machine secret store.

Useful signal text

Include hostname, job name, exit code, and a short runbook hint. Keep secrets out of the message body.

No agent required

Cron alerts are a send-only use case. Add the agent only when you want signed commands back to that host.

Quick start

go install github.com/nerve-ink/nerve-cli/cmd/nerve@latest
export NERVE_DSN="nerve://TOKEN:[email protected]"
0 2 * * * /opt/backup.sh || echo "backup failed on $(hostname)" | nerve send --severity alert

Capture the actual error

A cron alert is much more useful when it includes the last few lines of stderr. Keep the message short, but include enough context to know whether the failure is disk, network, credentials, or application logic.

LOG="/tmp/backup-cron.log"
if ! /opt/backup.sh >"$LOG" 2>&1; then
  {
    echo "backup failed on $(hostname)"
    tail -20 "$LOG"
  } | nerve send --severity critical
fi

Avoid repeated alerts

If a job runs every minute, add a cooldown file so one outage does not become hundreds of phone notifications.

LOCK="/tmp/nerve-backup-alert.lock"
if [ ! -f "$LOCK" ] || [ $(( $(date +%s) - $(stat -c %Y "$LOCK") )) -gt 3600 ]; then
  echo "backup still failing on $(hostname)" | nerve send --severity critical
  touch "$LOCK"
fi

FAQ

Can I use Nerve from cron?

Yes. Install the CLI, set NERVE_DSN, and pipe failure messages into nerve send.

Should cron use an agent token?

No. Use a sender DSN for alerts. Agent tokens are for remote signed actions.

Can the relay read cron output?

Payloads are encrypted before they are routed through the relay.