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?
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 usind screen -d
or Contr+A
and then :detach
and attach to it again using screen -r
). You can run the comand using screen 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 using tmux
and run python file.py
in the newly created session. You can detach using Contr+B
and d
or tmux 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.