Linux Labs

Packages, services, and logs / Stage 7 of 13

Diagnosing a failed service

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 8 · theory · 5 min

The outcome of a start

The summary of a failed service tells you at which stage the failure happened. This step shows how to read it.

On the Active line, after failed, the brackets hold the Result, how the attempt ended: exit-code — the process exited with a non-zero code, signal — a signal killed it, timeout — it ran out of time. The Process line below shows which command ran and its exit status: status=203/EXEC.

Codes from 200 to 255 come from systemd itself: it was preparing the start and could not complete it, so the program never began to work. Two common ones:

Code What failed
203/EXEC running the program from ExecStart: the file is missing or not executable
217/USER finding the user from the User line

A code below 200, such as 1/FAILURE, was returned by the program itself: it started and exited with an error. Its cause is found in the program's messages and settings.

systemctl show prints the same facts briefly:

bash
systemctl show lab-worker -p Result -p ExecMainStatus
Check yourself 1 question

A service went down, and its summary has this line. Where do you start looking for the cause?

    Process: 1532 ExecStart=/usr/local/bin/report-server (code=exited, status=1/FAILURE)
  • Autostart decides whether to start the service at boot. The Process line tells how the start ended: the program exited with an error.

  • Without the user, systemd would not have started the program and would have returned 217/USER. Code 1 came from a program that was already running.

  • Code 1 is below 200, so the program itself returned it, which means it started. With a wrong path systemd would have returned 203/EXEC.

Codes from 200 up come from systemd when it could not start the program. 1/FAILURE came from the program itself: it started and exited with an error, and its messages in sudo journalctl -u <service> give the cause.

Key points

  • Result on the Active line says how the attempt ended: exit-code, signal or timeout.
  • A code from 200 up means systemd could not start the program; a code below 200 came from the program itself.
Ubuntu 24.04
Loading…