Julian M
Julian M

Reputation: 15

Opening and running local terminal through SSH

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

Upvotes: 1

Views: 347

Answers (2)

nomadic73
nomadic73

Reputation: 54

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

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

Upvotes: 1

Space Light
Space Light

Reputation: 11

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

Upvotes: 1

Related Questions