Skip to content

Instantly share code, notes, and snippets.

@tolbkni
Last active March 7, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolbkni/f596252e70262166885470f03e35a259 to your computer and use it in GitHub Desktop.
Save tolbkni/f596252e70262166885470f03e35a259 to your computer and use it in GitHub Desktop.
A systemd script for user to run a jupyter notebook as daemon.
# /etc/systemd/user/jupyter-notebook.service
[Unit]
Description=Jupyter Notebook Service
After=network.target
[Service]
ExecStart=/usr/bin/jupyter-notebook --config=%h/.jupyter/jupyter_notebook_config.py
[Install]
WantedBy=default.target
@tolbkni
Copy link
Author

tolbkni commented Mar 7, 2019

Please run follow command to generate jupyter notebook config:

/usr/bin/jupyter-notebook --generate-config

New file will generated at $HOME/.jupyter/jupyter_notebook_config.py, you can change the default options. For example:

## Don't open the notebook in a browser after startup
c.NotebookApp.open_browser = False
## Allow remote access the notebook.
c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip = '0.0.0.0'

How to start service:

systemctl --user start jupyter-notebook.service

How to make service autostart:

systemctl --user enable jupyter-notebook.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment