systemctl status
does have what you're looking for:
$ systemctl status openproject-web-1.service
● openproject-web-1.service
Loaded: loaded (/etc/systemd/system/openproject-web-1.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-05-25 08:17:17 CEST; 1 day 4h ago
Process: 969 ExecStart=/usr/bin/openproject run web (code=exited, status=203/EXEC)
Main PID: 969 (code=exited, status=203/EXEC)
You see here under Main PID:
you have (code=exited, status=203/EXEC)
. That 203 is the exit code.
The exit codes are up to the specific application, but there are conventions. 0 is successful exit, 1-255 is abnormal exit, 256+ is out of range. The posix standard has a few special cases. But you'll want to look at the documentation of the application for anything more than that.
For example, grep(1)
says:
...the exit status is 0 if a line is selected, 1 if no lines were selected, and 2 if an error occurred
As JdePB describes below, systemd may set some exit codes itself in the range of 200 to 242. In the example above we have exit code 203
which means the actual execution failed (maybe the file was not found or was not marked as executable).