---
title: "Exit codes and failure signals in cron jobs"
url: "https://cronmissed.com/learn/exit-codes-and-failure-signals.md"
canonical_url: "https://cronmissed.com/learn/exit-codes-and-failure-signals"
last_updated: "2026-10-22"
type: "conceptual"
summary: "Read a job's exit status, send it to CronMissed with /<code>, and avoid the pipeline traps that hide a failure behind a zero."
related: ["https://cronmissed.com/learn.md", "https://cronmissed.com/learn/start-and-finish-pings.md", "https://cronmissed.com/docs/pinging-api.md", "https://cronmissed.com/guides/restic.md", "https://cronmissed.com/snippets/shell.md"]
---

# Exit codes and failure signals in cron jobs

> **For AI agents:** the complete index of CronMissed pages is [llms.txt](https://cronmissed.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Read a job's exit status, send it to CronMissed with /<code>, and avoid the pipeline traps that hide a failure behind a zero.

Every command ends with an exit status from 0 to 255. Zero means success and anything else means failure. Send it to CronMissed as the last part of the ping URL and a failed job alerts within seconds, instead of waiting for the missing success ping to time out.

## How do I send the exit status?

```crontab
/usr/local/bin/backup.sh; curl -fsS --retry 5 https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10/$?
```

The semicolon (and not `&&`) runs the ping whatever the job did, and `$?` holds the job's status. A status of 0 is a success ping; any other number marks the check down at once and records the number. `/fail` does the same without a number. Both accept a POST body with the error output.

## Which codes mean what?

| Code | Usual meaning |
| --- | --- |
| 0 | Success |
| 1 | General error; also the usual code for "found nothing" in some tools |
| 2 | Misuse of a shell built-in or a usage error |
| 126 | The command was found but could not be run, often a missing execute bit |
| 127 | Command not found, the classic sign of a PATH problem under cron |
| 128 + N | The process was killed by signal N; 137 means kill -9 and 143 means SIGTERM |

Tools define their own codes too. [restic](https://cronmissed.com/guides/restic.md), [BorgBackup](https://cronmissed.com/guides/borg.md) and [rsync](https://cronmissed.com/guides/rsync.md) each document codes for partial success, and a wrapper can map the ones you accept to 0.

## Which traps hide a failure?

- A pipeline reports the status of its last command. Use `set -o pipefail` in bash, or check `PIPESTATUS`.
- A script that ends with a harmless command, such as echo, exits 0 whatever happened before it. Add `set -e`, or exit with the real status.
- A shell function that swallows errors with `|| true` is a success by design.
- A PowerShell script sets no exit code unless you do; use `exit $LASTEXITCODE`.

## Questions

### What happens to a status above 255?

Exit statuses are one byte, so they wrap around: 256 becomes 0. Keep your own codes between 1 and 125.

### Can I send a message with the failure?

Yes. POST the last 100 kB of output to the same URL; it is kept with the ping and included in the alert for failures.

## Sources

- [BorgBackup documentation: return codes](https://borgbackup.readthedocs.io/en/stable/usage/general.html), read 22 October 2026

## Related pages

- [Start and finish pings](https://cronmissed.com/learn/start-and-finish-pings.md)
- [Pinging API](https://cronmissed.com/docs/pinging-api.md)
- [restic backups](https://cronmissed.com/guides/restic.md)
- [Shell and curl](https://cronmissed.com/snippets/shell.md)

## Related

- [Cron monitoring explained: concepts and fixes](https://cronmissed.com/learn.md)
- [Start and finish pings for long-running jobs](https://cronmissed.com/learn/start-and-finish-pings.md)
- [Pinging API reference](https://cronmissed.com/docs/pinging-api.md)
- [Monitor restic backups with exit codes](https://cronmissed.com/guides/restic.md)
- [Ping CronMissed from a shell script with curl](https://cronmissed.com/snippets/shell.md)
