Start Jupyter Server at Boot Time

Q

How to Start Jupyter Server at boot time?

✍: FYIcenter.com

A

If you are sharing your Jupyter server to multiple users, you may want to run it at boot time. So the server will be available immediately after the computer started.

Running Jupyter server at boot time faces some challenges:

1. Jupyter server seems to be designed for non-root users. If you run it as root, you will get the following error message.

fyicenter$ sudo jupyter notebook

[E 15:56:31.172 NotebookApp] [nb_conda_kernels] couldn't call conda:
    [Errno 2] No such file or directory: 'conda'

[I 15:56:31.172 NotebookApp] [nb_conda_kernels] enabled, 0 kernels found

[I 15:56:33.554 LabApp] JupyterLab extension loaded from
  /usr/local/anaconda3/lib/python3.8/site-packages/jupyterlab

[I 15:56:33.554 LabApp] JupyterLab application directory is
  /usr/local/anaconda3/share/jupyter/lab

[C 15:56:33.557 NotebookApp] Running as root is not recommended.
  Use --allow-root to bypass

2. The default configuration file is hidden in user's home directory. You can also move it to a better location and provide it to the "jupyter" command as an option.

fyicenter$ mv ~/.jupyter/jupyter_notebook_config /var/local

fyicenter$ jupyter notebook --config /shared/jupyter_notebook_config.py

3. The Notebook file directory should be provided as a shared directory:

fyicenter$ vi /shared/jupyter_notebook_config.py

...
c.NotebookApp.notebook_dir = '/shared/notebooks'

4. Read/write permissions should be given to the Notebook file directory '/shared/notebooks'. Otherwise you will get the permission error.

Web portal error:
  Creating Notebook Failed
  An error occurred while creating a new notebook.
  Permission denied: untitled.ipynb

Solution:
  fyicenter$ sudo chmod -R 777 /shared/notebook/

5. You may also get more permission issues, if you have 'nbconvert' installed.

Web portal error:
  500 : Internal Server Error

Server log error:

  not able to open '/usr/local/anaconda3/share/jupyter/nbconvert/templates/html/':
    not enough permission

Solution:
  fyicenter$ sudo chmod -R 777 /usr/local/anaconda3/share/jupyter/nbconvert/templates/html/

6. Run it as @reboot crontab job with full path.

fyicenter$ crontab -e

@reboot /usr/local/anaconda3/bin/jupyter notebook \
  --config /shared/jupyter_notebook_config.py >> /shared/jupyter.log 2>&1

7. Reboot the computer. Jupyter sever should be started automatically.

 

Terminate Jupyter Notebook Execution

Notebook Directory for Jupyter Server

Installing and Running Jupyter

⇑⇑ Jupyter - Frequently Asked Questions

2022-04-13, 400🔥, 0💬