systemd startup debugging

This commit is contained in:
buchel_k committed 2025-12-19 09:17:21 +01:00
1 parent 806a3650b3
commit 03e09a9d7d
1 file changed
+43 -1
+43 -1
View File
@@ -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`.
`/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.