The simple but correct way to have a bash script send output to systemd journal?
11
votes
2
answers
6587
views
I have simply been sticking something like this at the top of my bash scripts. This still works with systemd. (I have used it for a long time and I don't fully understand it. It just works, so I use it.)
exec 5> >(logger -t $0)
BASH_XTRACEFD="5"
PS4='$LINENO: '
set -x
Even with systemd, the above commands give the expected output in journalctl. However, it seems that maybe I should be using something like this instead.
systemd-cat -t $0
How should I alter my current logging commands under systemd?
(I'm looking for the same kind of simple-minded solution where I can paste a few lines and get some output in the journal.)
Asked by MountainX
(18888 rep)
Sep 19, 2017, 04:39 AM
Last activity: Apr 11, 2025, 09:27 PM
Last activity: Apr 11, 2025, 09:27 PM