Skip to content

Commit

Permalink
Add Guide for Preventing JupyterHub Server Timeout (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
arpita0911patel authored Dec 18, 2024
2 parents c50d238 + 1b6a22f commit 8e6eac1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 6
title: "Prevent Server Timeout"
description: "
Currently, user servers on JupyterHub stop after about an hour of inactivity. While this helps save costs, it can be problematic for long-running jobs if there is no active interaction with the notebook."
tags:
- 2i2c
- JupyterHub
- timeout
- notebook
- tutorial
---
# Preventing JupyterHub Server Timeout for Long-Running Jobs

JupyterHub servers typically stop after about an hour of inactivity to help manage computational reosurces. This can be present challenges for users who need to run long-running jobs. You have two options to keep your JupyterHub server active for longer periods:


### 1. Jupyter Keepalive Extension

The Jupyter Keepalive extension provides an easy way to control your server's active time.
- To install the extension, open a terminal and run:

```bash
pip install jupyter-keepalive
```

- Use the JupyterLab Command Palette (Command+Shift+C on Mac or Control+Shift+C on Linux/Windows) to select the "Keep server alive while idle" option.
- Once your task is complete, it's crucial that you then use the Command Palette to select the "Stop keeping server alive" option. This will ensure that the server is no longer being kept active unnecessarily.
<img src="/img/server-keepalive.png" width="700" alt="image of jupyterlab command palette" />

### 2. Using `time.sleep()` (Alternate Method)

As an alternative, you can create a separate notebook with the following code and run the cell before starting your job.

```python
import time
time.sleep(24 * 60 * 60) # Sleeps for 24 hours
```
Binary file added static/img/server-keepalive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8e6eac1

Please sign in to comment.