How to make automatic shutdown of notebook when notebooks are idle for long hours.

1,607 views
Skip to first unread message

Jafar Sharif

unread,
Feb 6, 2019, 5:59:22 AM2/6/19
to Project Jupyter
Hi,
   Is there a way to make the notebooks that are idle for long hours (closing the notebook window without shutdown) to shutdown automatically with config file/script.
I have found in documentation that it can be done through the config file. But even after implementing it is unable to kill the notebooks that are idle for long hours.
c.MappingKernelManager.cull_idle_timeout=3600  c.MappingKernelManager.cull_interval=300

Above are the settings that i have made in the config file.

Please let me know how to do it or is there any changes that i haven't made .

Thanks
Jafar

jupyter_notebook_config (1).py

Kerwin Sun

unread,
Feb 6, 2019, 10:50:42 AM2/6/19
to jup...@googlegroups.com
I have a PR about autoshutdown kernel. https://github.com/jupyter/notebook/pull/4306.
Maybe this can help you.😁

Jafar Sharif <jafars...@gmail.com> 于2019年2月6日周三 下午6:59写道:
--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/41d3929d-2521-49e8-ab73-0c70311d7ea7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luciano Resende

unread,
Feb 6, 2019, 1:28:51 PM2/6/19
to jup...@googlegroups.com
This article should provide you with all the info required to use
kernel culling.

https://developer.ibm.com/code/2017/10/26/limit-notebook-resource-consumption-culling-kernels/
> --
> You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
> To post to this group, send email to jup...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/41d3929d-2521-49e8-ab73-0c70311d7ea7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Luciano Resende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Jafar Sharif

unread,
Feb 7, 2019, 12:11:00 AM2/7/19
to jup...@googlegroups.com, luckb...@gmail.com
Hi Luciano,
       I have followed the same thing that has mentioned in the blog but even though it is not killing the idle kernels. I am attaching the config file of mine can you check it once and let me know is there any additional config changes need to be done to make it work.

Thanks
Jafar

jupyter_notebook_config.py

Roland Weber

unread,
Feb 7, 2019, 1:53:37 AM2/7/19
to Project Jupyter
Have you checked that you're on a recent version of Jupyter Notebook?

Are the kernels actually idle, or could they still be executing a long-running cell?

Have you tried to enable debug logging, to see if the culling is actually attempted?

Jafar Sharif

unread,
Feb 7, 2019, 8:57:03 AM2/7/19
to jup...@googlegroups.com, rolw...@de.ibm.com
Hi Roland, 
       Let explain you my case for achieving it. We have jupyterhub in an aws instance and have different logins for different user, Sometimes we all  work on the same user and people will start working on the tasks and in the end of the they will close the notebook without shutdown. In this case it is consuming the most of the instance . so i am thinking of is there anyway to kill the kernals that are running for long hours(idle kernels). So i have seen in the jupyter notebook documentation from 5.1.0 they have introduced the killing of the kernels through config file.With the help of documentation file i have generated the config file and made changes as per the documentation. My current jupyter version is 5.7.1.. Can you please let me know what changes need to be done in the config file. I have attached the config file.

Thanks 
Jafar

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
jupyter_notebook_config.py

Jafar Sharif

unread,
Feb 11, 2019, 3:33:35 AM2/11/19
to Project Jupyter
Hi Roland, 
       Let explain you my case for achieving it. We have jupyterhub in an aws instance and have different logins for different user, Sometimes we all  work on the same user and people will start working on the tasks and in the end of the they will close the notebook without shutdown. In this case it is consuming the most of the instance . so i am thinking of is there anyway to kill the kernals that are running for long hours(idle kernels). So i have seen in the jupyter notebook documentation from 5.1.0 they have introduced the killing of the kernels through config file.With the help of documentation file i have generated the config file and made changes as per the documentation. My current jupyter version is 5.7.1.. Can you please let me know what changes need to be done in the config file. I have attached the config file.

Thanks 
Jafar

Kevin Bates

unread,
Feb 11, 2019, 7:03:39 PM2/11/19
to Project Jupyter
Hi Jafar.  Adding to Roland's questions...

Per the attached config file, you have not enabled culling.  The culling options that you have apparently modified are still commented out.  Remove the comment character for those options to 'activate' them.  In addition, there may be other steps involved for "exposing" Notebook configuration files within a JupyterHub environment. (I'm unfamiliar with Hub so perhaps others can confirm.)  Finally, I believe Hub may have (or is in the process of having) the capability to cull the spawned Notebook servers.  If I recall the various threads of conversation on this, I think Hub's culling of Notebook servers also considers the notebook server's kernel's idle time.  However, what I'm not certain about is if the culling of Notebook servers (by Hub) is dependent on enablement of the culling of kernels within the Notebook server vs. a different Hub-scoped configuration option for culling the spawned NB server.
Reply all
Reply to author
Forward
0 new messages