0

I am running Python on a Raspberry Pi and everything works great. I have a small script running on the system start up which prints several warning messages (which I actually cannot read since it is running in the background)...

My question is: Is there a way via SSH to "open" this running script instance and see what is going on or a log file is the only way to work with that?

Thanks!

2 Answers2

1

Try using the Python logging library. You can configure it to save the output to a file and then you can use tail -f mylogfile.log to watch as content is put in.

EDIT:

An alternative is to use screen. It allows you to run a command in a virtual console, detach from that console, and then disconnect from the machine. You can then reconnect to the machine and re-attach to that console and see all the output the process made. I'm not sure about using it on a script that starts when the machine is turned on, though (I simply haven't tried it).

Tim Tisdall
  • 9,914
  • 3
  • 52
  • 82
0

You should modify your python script to write its output to a file instead of to the screen (which you can't see). I.e., I think that a log file is your best (possibly only) bet. You can write to a file in /tmp on the raspberry pi if you just want a temporary log file that you can check once and a while. Also, as Tim said, you could try out the python logging library, but I think just writing to a file is quicker and easier, although you might run into some issues with permissions...

hft
  • 1,245
  • 10
  • 29