Job Executionintermediate

What is Exit Code?

A numeric value returned by a process to indicate success (0) or a specific type of failure.

Definition

An exit code (or return code) is an integer that a program returns to its caller upon completion. By convention, 0 means success and any non-zero value indicates an error. Specific codes have standard meanings: 1 for general errors, 126 for permission denied, 127 for command not found, and 137 for killed by signal (out of memory). In HTTP-based cron jobs, the equivalent concept is the HTTP status code.

๐Ÿ’ก

Simple Analogy

Like a doctor giving you a report after a checkup: "0" means you're healthy, and any other number is a diagnosis code telling you exactly what is wrong.

Why It Matters

Exit codes tell you not just whether a job failed, but why it failed. A script returning exit code 1 has a different root cause than one returning 137 (killed by OOM). In CronJobPro, HTTP status codes serve the same purpose โ€” a 500 (server error) requires different action than a 401 (authentication expired).

How to Verify

For shell scripts, check $? after execution: `echo $?`. In CronJobPro, the HTTP status code is recorded for every execution and displayed in the execution detail view. Filter execution history by status code to find patterns.

โš ๏ธ

Common Mistakes

Not setting explicit exit codes in scripts, causing all failures to return a generic code 1. Treating all non-zero exit codes the same instead of handling each appropriately. In HTTP jobs, ignoring 3xx redirect codes that may indicate a configuration change.

โœ…

Best Practices

Design your scripts to return meaningful, documented exit codes for different failure scenarios. In HTTP jobs, use CronJobPro's expected status code feature to define what constitutes success. Log the exit code alongside error details for faster debugging.

Documentation

Read the full docs

Try it free โ†’

Frequently Asked Questions

What is Exit Code?

An exit code (or return code) is an integer that a program returns to its caller upon completion. By convention, 0 means success and any non-zero value indicates an error. Specific codes have standard meanings: 1 for general errors, 126 for permission denied, 127 for command not found, and 137 for killed by signal (out of memory). In HTTP-based cron jobs, the equivalent concept is the HTTP status code.

Why does Exit Code matter for cron jobs?

Exit codes tell you not just whether a job failed, but why it failed. A script returning exit code 1 has a different root cause than one returning 137 (killed by OOM). In CronJobPro, HTTP status codes serve the same purpose โ€” a 500 (server error) requires different action than a 401 (authentication expired).

What are best practices for Exit Code?

Design your scripts to return meaningful, documented exit codes for different failure scenarios. In HTTP jobs, use CronJobPro's expected status code feature to define what constitutes success. Log the exit code alongside error details for faster debugging.

Related Terms