Menu

Debugging macOS LaunchAgent Failures With launchctl and Exit Code 78
📰

Debugging macOS LaunchAgent Failures With launchctl and Exit Code 78

#hackernoon#technology#plist#last#exit
Reading 0:00
15s threshold

Every morning at 7:45, a job on my Mac runs a reconciliation and posts the results for the finance team. It's an ordinary LaunchAgent: a plist in ~/Library/LaunchAgents , a Python script, and a log file.

For three mornings in October, it didn't run.

Nothing told me. There was no error in Slack, because the code that sends errors never started. There was no crash report. And the log file, the first place anyone looks, had nothing new in it, because the job failed before it could write a line.

The only clue was a number.

Where the clue was

launchd keeps a record of every job's last exit. Ask for it:

launchctl print gui/$(id -u)/com.example.cash-recon | grep -E "runs|last exit code"

runs = 1 last exit code = 78: EX_CONFIG

The labels in this post are examples. For a quick look at every job, launchctl list shows the last exit status in its second column.

78 is EX_CONFIG from sysexits.h , a configuration error.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.