Skip to content

systemd: Job failed because the control process exited with error code

Linuxtested on Bash 5.3, systemd, Ubuntu 26.04

A script running as a oneshot service returns a non-zero exit code. systemd turns that into the state failed – exactly what monitoring should see.

Symptom

systemctl --user start notes-check.service; echo "start: $?"
Job for notes-check.service failed because the control process exited with error code.
See "systemctl --user status notes-check.service" and "journalctl --user -xeu notes-che…
start: 1

In the course the proxy of the checked service is stopped – notes-check reports that with exit code 1.

Diagnosis

Query the unit's result and exit code and list failed units.

systemctl --user show notes-check.service -p Result -p ExecMainStatus
systemctl --user --failed --no-pager --plain | grep -o 'notes-check.service.*failed'
Result=exit-code
ExecMainStatus=1
notes-check.service loaded failed failed

Causes

ExecMainStatus=1The script reports an error

notes-check probes the service and exits with 1 when it does not answer. systemd takes that exit code as the result.

Fix

Fix the cause (here: start the proxy again) and run the unit once more.
docker compose -f ~/sh-lab/notes/compose.yaml start proxy >/dev/null 2>&1
notes-wait 10 >/dev/null && systemctl --user start notes-check.service
systemctl --user show notes-check.service -p Result
Result=success

Don't: Always end the script with exit 0 to keep the unit green. Monitoring then never sees an outage.

▶
Break it yourself and find it – free
Shell scripting hands-on, Day 13: scheduling scripts with cron and systemd timers.
Go to day 13 →

FAQ

How do I get notified on failure?

With OnFailure= in the unit pointing to a unit that sends a message – or by polling systemctl --failed.

Where does the script's output go?

Everything the script writes to stdout and stderr lands in the unit's journal: journalctl --user -u notes-check.service.

Related error patterns

More