1

I'm trying to start a python script on my Raspberry Pi through an SSH connection from my main machine. But obviously, as soon as I turn off my main machine the SSH terminal will close and with that my python script will be cancelled.

I'm looking for a method where I can use SSH to open a terminal that runs on the Pi internally and does not close as soon as I turn off my main machine. This should be possible without connecting keyboard and screen to the raspberry, right?

Thank you so much for any tips

1

2 Answers 2

1

you can use screen, tmux or nohup for this:

screen: screen manager with VT100/ANSI terminal emulation

tmux: terminal multiplexer

nohup: run a command immune to hangups, with output to a non-tty

screen and tmux will start virtual session that you can connect to later, for hotkeys settings see manual pages

nohup will just avoid to kill the process for example: yes nohup;
this will write the output from the program "yes" to the nohup.out file and it will not be terminated by disconnection of your ssh

Sign up to request clarification or add additional context in comments.

Comments

1

This was answered over on stack exchange - https://unix.stackexchange.com/a/266573

ssh myuser@hostname screen -d -m "python somepath.py -s 'potato'"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.