0

I have a Raspberry Pi which I use to run a Python script 24/7. I can remotely access it from my Linux laptop using SSH. But connecting to it using ssh <username>:<address> will create a new session instead of accessing the current session running in my Pi. Is there a way of using SSH so that I can see what my Python script is doing remotely and terminate and restart it remotely if necessary?

Effectively, I would like my laptop to be able to show me whatever is currently being displayed in my Pi.

1

The easiest way of doing so is using tmux (or screen, which is an older utility).

When you ssh into your Raspberry Pi install & run tmux (no options needed) you'll get a tmux session, that you can run your Python script it, to detach press CTRL + B following with the letter D.

The script will continue running in the background, to get back just write tmux attach.

  • Fantastic, this is exactly what I was looking for and it works as a charm. I've been using tmux for quite some time, but mainly for having multiple panes in my laptop's terminal. I wasn't aware you could attach and detach a session, much less doing so remotely via ssh. Thank you so much. – gilbertohasnofb Sep 5 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.