Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep python code running after closing shell

I'm working on a problem on a remote server (I use ssh to connect). As I'm new to the domain, I'm using jupyter-notebook, so that I can examine and code. Some parts of my code take a long time to run(like maybe 4-5 hours) and I'm not able to maintain my connection that long. How can I keep my code running after the shell is closed? Should I just copy it into a .py file and use commands like tmux or screen?

like image 587
P.Alipoor Avatar asked Dec 09 '25 09:12

P.Alipoor


1 Answers

Use screen.

$ screen

This will create a screen session and when you are done, you can use the keys ctrl-a-d to detach.

To go back:

$ screen -list

This will show the list of detached screen sessions. To connect

$ screen -r

like image 164
idisposable11 Avatar answered Dec 10 '25 22:12

idisposable11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!