Thursday, October 28, 2021

[SOLVED] Jupyter how to run cells on background?

Issue

Usually, if the network connection is lost or the web browser is closed while cells are running i have to run cells again from the beginning.

To deal with this i converted .ipynb to .py and used 'nohup python .py'

Is there any way to prevent running cells from stopping like nohup?

Thank you in advance.


Solution

According to https://github.com/jupyter/notebook/issues/2446

Anything already running in the notebook will keep running, and the kernel it started for that will stay running - so it won't lose your variables. However, any output produced while the notebook isn't open in a browser tab is lost; there isn't an easy way to change this until we have the notebook server able to track the document state, which has been on the plan for ages.

When you close tab it does not mean the process was ended, it keeps running background without output.

I am not sure if there is any way to achieve this now, but I found that if you are using jupyterhub, you can continue run ipython a terminal tab, when the tab was closed or switch to another device (close previous web page), all output reserved. Maybe screen or tmux is better?



Answered By - Jay