Skip to content

Instantly share code, notes, and snippets.

@nokados
Forked from whophil/jupyter.service
Last active March 31, 2020 12:48
Show Gist options
  • Save nokados/d9beae1ba4847c475ae97a40274d389e to your computer and use it in GitHub Desktop.
Save nokados/d9beae1ba4847c475ae97a40274d389e to your computer and use it in GitHub Desktop.
A systemd script for running a Jupyter notebook server.
# After Ubuntu 16.04, Systemd becomes the default.
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/nokados/anaconda3/bin/jupyter-notebook --config=/home/nokados/.jupyter/jupyter_notebook_config.py --no-browser
User=nokados
Group=nokados
WorkingDirectory=/home/nokados
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target
@nokados
Copy link
Author

nokados commented Jan 24, 2019

Following the instructions of https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples, place this file in:

/usr/lib/systemd/system/jupyter.service

Then execute

sudo systemctl enable jupyter.service
Reload the systemd daemona and restart the service

sudo systemctl daemon-reload
sudo systemctl restart jupyter.service

@nokados
Copy link
Author

nokados commented Mar 31, 2020

(Blocking request with no referer) Encountering this too, I was only able to get it to work with c.NotebookApp.disable_check_xsrf = True, which is not recommended for security reasons.

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