I am not able to figure out what option to pass in StandardOutput=
for a
unit file (.service
), where I want to show some messages on the connected terminal
from where the service is started! (console
/tty
doesn't seem to be what I want)
Maybe /etc/systemd/system.conf
's global default DefaultStandardOutput=journal
can be changed, but I don't want to do that!
I am only interested in showing some progress/startup messages from my unit file
(like systemd-run -P
)
I am on Ubuntu 18.04.2
# systemd --version
systemd 237
You can take a look at https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
If I understand the question correctly you want the service outputs status to tty / console? Remember that when a service is started systemd take care of default file descriptors.
You can use a file to store the status and query it there.
Edit your script you want to run using systemd and add
| logger
to command you want output from to syslog:Output of
$ sudo journalctl -u pstofile -f
is:My systemd service file contains the next:
Its been quite long, I just want to update how I solved this. I created a POSIX MQ, on which a daemon listens on. This daemon is in charge of displaying to the current pty (
mq_receive()
+write()
). All the daemons send a message on the queue when they start, and when they stop (withmq_send()
)When I start the main service, I will also start this display service giving it, the pty info.