Issue
I am using ssh
to connect to another (faster) computer in order to run some python code there. As I expect it to run several hours, I would like to disconnect after running it, like this:
$ ssh user@my-other-computer
$ python file.py &
$ exit
However, if I try this, I get the message:
zsh: you have running jobs.
I tried using nohup
:
$ nohup nice python file.py &
but to no avail.
How can I achieve my goal?
Solution
I don't know why nohup
does not work (maybe because of the nice
, it could work without the nice
command) but there are alternatives:
screen
creates a new terminal that is not bound to your session (you can detach a screen session usindscreen -d
orContr+A
and then:detach
and attach to it again usingscreen -r
). You can run the comand usingscreen python file.py
tmux
is a terminal multiplexer. It is like screen but has more features and it's faster. You can open a tmux session usingtmux
and runpython file.py
in the newly created session. You can detach usingContr+B
andd
ortmux detach-client
.disown
is a shell command that disowns all jobs from the current shell that you can close it and the jobs will stay running.
Answered By - dan1st