I have a service that I want to run under systemd. It is written in perl, where by default output is line buffered if STDOUT
is connected to a terminal. (Which seems similar to python)
The consequence is output arrives to journalctl -f -u my.service
in chunks of many lines at a time - when the buffer runs full.
I know I can modify the service source to auto-flush STDOUT
($|=1
in perl).
I know I can also use unbuffer
from expect:
-ExecStart=/my/program.pl
+ExecStart=/usr/bin/unbuffer /my/program.pl
but then I get another process involved and such a "solution" has a bad smell to me. (E.g. the "Main PID" is that of unbuffer
, not of /my/program.pl
). And the whole point of systemd is to avoid weird shell workarounds like this one.
So is there some way I can run such services unaltered in a way that makes them think they're connected to a terminal so they flush their STDOUT
? I've looked at StandardOutput=
but didn't find anything useful.