How to automatically shut down long-running notebooks

It’s easy to forget about interactive sessions (Jupyter notebooks, RStudio) and accidentally leave them running, which can accrue unwanted charges or clog your computing resources. To prevent this, we’ve developed a customizable project using the Domino API and run scheduler to automatically shut down long-running sessions for you.


1. Log into and search for the project "ty/autoshutdown". Fork your own version of that project. 

Note: If you're using a VPC or on-premise installation, reach out to our support team and we'll help you get access to the project on your system. Optionally, you can use the KB article for Moving a Project from one deployment to another.



2. In Settings, on the Access & Sharing tab, set your project to be private. This will ensure only you and those you invite have access to your project.

3. Take note of:

  1. the environment variable DOMINO_USER_API_KEY to store your api key. This is handled automatically for you by Domino.
  2. The fact that this solution uses python, and also has two dependencies listed for pip in requirements.txt

4. The project mentioned herein contains an Jupyter interactive notebook with a bare bones test to stop a run manually. To use that test, you simply need a running session and its run ID. Once you have explored that, you can take a look at step 5.

5. The script checks to see which runs have been running for longer than the threshold you set and shuts them down. Schedule to run on a regular basis.

  1. Click Schedule on the menu on the left.
  2. Enter the command to run: [project_owner] [project_name] [threshold_in_hours]
    • Example would be johnjoo crimemaps 4, which tell the script to shut down any projects in johnjoo/crimemaps that have been running for more than 4 hours.
  3. Determine how often you want to check and shutdown your runs.
    • A frequency of every day or every hour is pretty reasonable.
  4. Click Schedule button at the bottom of the page.


Was this article helpful?
0 out of 0 found this helpful