简体   繁体   中英

Linux: How to monitor and incoming ssh session on an attached monitor

I am ssh'ing into my rasperrybi and running a python script. I need to leave the program running overnight and capture the output of the program on a monitor that is attached to the pi. How can I accomplish this?

You could background your process so it will run when your ssh session is no longer running. End command with '&'. Then you can use the system command 'wall' to send messages to other users. That should display messages form your process on the console.

The tee command allows you to take standard out from a program, append it to a file, and also send it to standard out. For example:

$ echo "Hello world" | tee -a teetest.txt
Hello world
$ cat teetest.txt
Hello world
$

Using this method, your Python script's output can still be sent to the monitor connected to your R-Pi, but it will also be captured to a file.

In addition, your operating system may have a program installed called script . Its purpose is to do pretty much exactly what you're looking for -- capture traffic (optionally in to and) out from a program that you're running. Only it would be used to "wrap" your Python script rather than merely process its output after the fact.

Usage varies between unices, but in FreeBSD (which I use on my R-Pi), you could do this:

script output.txt ./myscript.py

If you're using something other than FreeBSD, try reading the man page included with your OS in order to learn usage and options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM