How to make a realtime log in the terminal?

You need to work the script around and logginova message in a predetermined place, and in another terminal, they would appear as they are received.

The solution:
• Just write in logimouse terminal.
echo “$message” > /dev/virtual terminal tty2
The problem is that the numbers of the terminals are dynamically created and adjust the main script in each run do not want to.
• To write to a file.
Then you have to write a viewing program with an infinite loop, monitoring the difference, udalenie. I think it's bold for such a task.
• Write to the pipe.
tty1: ping toster.ru > pipe
virtual terminal tty2: cat pipe

What you need! But the pipe will block the main script, if nobody will read it.

It may be possible to find out whether the pipe is full before writing to it?
Or is there some standard solution?
March 19th 20 at 09:23
3 answers
March 19th 20 at 09:25
Solution
• To write to a file.
Then you have to write a viewing program with an infinite loop, monitoring the difference, udalenie. I think it's bold for such a task.

tail-f FILE

you can still as a variant:
mkfifo fileFIFO #create a file(named pipe) fifo
exec 4<>fileFIFO #open the file handle for read/write
echo Test1 >&4
...
echo TestN >&4
exec 4>&- #close

to read(from the opening to the closing):
cat fileFIFO
If the log will be handled with something like logrotate, it is better to use tail-F (lowercase f instead). - donnie_Waters86 commented on March 19th 20 at 09:28
March 19th 20 at 09:27
lnav
March 19th 20 at 09:29
the terminal run the program script
$ ping 8.8.8.8 | logger -t mycmd

any other terminal
$ journalctl -ft mycmd

Find more questions by tags Loggingbash