From 03e09a9d7dabe9c9667415e061b81f4e215c330e Mon Sep 17 00:00:00 2001 From: Konrad Bucheli Date: Fri, 19 Dec 2025 09:17:21 +0100 Subject: [PATCH] systemd startup debugging --- admin-guide/troubleshooting/systemd.md | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/admin-guide/troubleshooting/systemd.md b/admin-guide/troubleshooting/systemd.md index c01fce70..82247357 100644 --- a/admin-guide/troubleshooting/systemd.md +++ b/admin-guide/troubleshooting/systemd.md @@ -23,4 +23,46 @@ systemctl list-timers ## Logs All systemd logs end up in journald. One important exception is __sssd__ which provides authentication against Active Directory. Its logs can be found in -`/var/log/sssd`. \ No newline at end of file +`/var/log/sssd`. + + +## Debug Service Start Failure + +### Wrapper to Catch Output + +To catch all the output in a file write a small wrapper: +``` +#!/usr/bin/bash + +LOGFILE=/tmp/test.log +echo "$(date): " "$@" >> $LOGFILE +exec "$@" &>> $LOGFILE +``` +and store it e.g. as `/root/systemd_debug_starter.sh`. +Then inject it into the daemon startup in the unit file with +``` +ExecStart=/root/systemd_debug_starter.sh $ORIGINAL_EXECUTABLE +``` +then you need to run +``` +systemctl daemon-reload +systemctl start $SERVICE + +``` +and check out the log file. + + +### Strace + +If the error is more subtle, like problems with `SIGPIPE`, `strace` can be useful to unveil the problem. +You may inject strace into the daemon startup in the unit file with +``` +ExecStart=strace -D -f -o /tmp/strace.txt $ORIGINAL_EXECUTABLE +``` +then you need to run +``` +systemctl daemon-reload +systemctl start $SERVICE + +``` +and check out the log file.