Mailinglist Archive: opensuse (1239 mails)

< Previous Next >
Re: [opensuse] systemd: What is the proper manner to print a message to the screen from a service file?
  • From: "Carlos E. R." <robin.listas@xxxxxxxxxxxxxx>
  • Date: Sun, 16 Jun 2013 20:49:34 +0200 (CEST)
  • Message-id: <alpine.LNX.2.00.1306162032110.16617@Telcontar.valinor>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On Sunday, 2013-06-16 at 14:29 -0400, Cristian Rodríguez wrote:
El 16/06/13 14:21, Carlos E. R. escribió:

I do not want to execute anything by hand. I want just to look at my
screen be told if there is something to see. Just tell me how to print
the output of a command on the screen, please, from inside a service file.

You are trying to solve a problem the weirdest and arcanest way possible!

I'm simply customising my system to my tastes, as simple as that. :-)


If you want to see "failed" or "sucess" of services like you did in sysvinit at boot in tty1 remove "quiet" from the boot command line.

I have that removed since days, that's not it. I want a summary at the end of the boot; to be exact, the output of a command.


Otherwise please read the documentation, man page systemd.exec , option StandardOutput, yoiu can send the output to a tty/syslog/journal etc.

It works, thanks :-)

Ok, I have:

Telcontar:~ # cat /etc/systemd/system/helloworld.service
[Unit]
Name=Plays a welcome sound when target multi-user is reached
After=multi-user.target
# graphical.target - multi-user.target

[Service]
Type=oneshot
RemainAfterExit=true
StandardOutput=tty
ExecStart=-/usr/local/bin/helloworld

[Install]
WantedBy=multi-user.target
Telcontar:~ #



Telcontar:~ # cat /usr/local/bin/helloworld
#!/bin/bash
# -x
#
# Author: Carlos E. R.
#
# Supersedes /etc/init.d/helloworld
# called from /etc/systemd/system/helloworld.service

cat /usr/share/sounds/au/hal9.au > /dev/audio &
/bin/logger -t Mine -p syslog.info "Saying hello world"

#Does not print - it does on syslog, not to terminal.
grep FAILED /var/log/boot.log
Telcontar:~ #



It plays that cute sound file, and echoes the failed list to tty1, just what I want, at the end of the boot sequence.


- -- Cheers,
Carlos E. R.
(from 12.3 x86_64 "Dartmouth" at Telcontar)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlG+CL4ACgkQtTMYHG2NR9Wx7ACdE1g28QnArHe+rxwe2HxZS7z5
2z0AnjKYkUSf9TniT15ItEj+766EZCCa
=Z84P
-----END PGP SIGNATURE-----
< Previous Next >
Follow Ups