Mastering Development System & Network

Can many script instances write to tty (parallel)?

I have recently migrated my upstart scripts to systemd, unlike upstart, I don’t
see any output on the tty for services being started/stopped. To get that visual
feedback, I added something like

      echo "Starting $UNIT_NAME" > $MYTTY

Where the MYTTY is an environment variable I am setting from output of tty command.
I have 20 odd services but somehow not all messages were appearing on my tty. So I changed
the line (just to check) to:

      echo "Starting $UNIT_NAME" | write myuser $MYTTY

And with this, I see all the messages being displayed! (of course, with the additional
Message from <user>@<hostname> on <term> at <time> ... EOF

Just to check if write is doing something special, I checked the code in bsdutils and
I didnt find anything special, its just writing character by character (with some handling
for special chars and CR, LF)

What is wrong with :

      echo "Starting $UNIT_NAME" > $MYTTY

I also tried:

      echo -e "Starting $UNIT_NAME\r\b" > $MYTTY

etc. But still I don’t see messages from all the services on the screen!
Is it because systemd starts up all services in parallel that some
writes to the tty vanish !?

Leave a Reply

Your email address will not be published. Required fields are marked *