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
nohupdoes not work (maybe because of thenice, it could work without thenicecommand) but there are alternatives:screencreates a new terminal that is not bound to your session (you can detach a screen session usindscreen -dorContr+Aand then:detachand attach to it again usingscreen -r). You can run the comand usingscreen python file.pytmuxis a terminal multiplexer. It is like screen but has more features and it's faster. You can open a tmux session usingtmuxand runpython file.pyin the newly created session. You can detach usingContr+Banddortmux detach-client.disownis a shell command that disowns all jobs from the current shell that you can close it and the jobs will stay running.