Skip to content

Instantly share code, notes, and snippets.

@MiXaiLL76
Forked from whophil/jupyter.service
Last active June 12, 2020 08:10
Show Gist options
  • Save MiXaiLL76/18f4d64963447ec46d0d0ecb73430f5e to your computer and use it in GitHub Desktop.
Save MiXaiLL76/18f4d64963447ec46d0d0ecb73430f5e to your computer and use it in GitHub Desktop.
A systemd script for running a Jupyter notebook server.
# Setting up a Jupyter Lab remote server raspberry
[Unit]
Description=Jupyter Lab
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/pi/.local/bin/jupyter-lab --config=/home/pi/.jupyter/jupyter_notebook_config.py
User=pi
Group=pi
WorkingDirectory=/home/pi/
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target
@MiXaiLL76
Copy link
Author

MiXaiLL76 commented Mar 18, 2020

Generate config file

pi@raspberrypi:~ $ jupyter notebook --generate-config
Writing default config to: /home/pi/.jupyter/jupyter_notebook_config.py

pi@raspberrypi:~ $ jupyter notebook password
Enter password: ****
Verify password: ****

Edit config

c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False

Create service

wget https://gist.github.com/MiXaiLL76/18f4d64963447ec46d0d0ecb73430f5e/raw/dd7a029330435d590e5887055109f9bd57174e57/jupyter.service -O /etc/systemd/system/jupyter.service

Execute service

sudo systemctl enable jupyter.service

Reload the systemd daemona and restart the service

sudo systemctl daemon-reload
sudo systemctl restart jupyter.service

@MiXaiLL76
Copy link
Author

service for ubuntu

# Setting up a Jupyter Lab remote server raspberry

[Unit]
Description=Jupyter Lab

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/ubuntu/.local/bin/jupyter-lab --config=/home/ubuntu/.jupyter/jupyter_notebook_config.py
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/
Restart=always
RestartSec=10
#KillMode=mixed

[Install]
WantedBy=multi-user.target

@MiXaiLL76
Copy link
Author

Setting up a Jupyter Lab remote root ubuntu server

/etc/systemd/system/jupyter.service

[Unit]
Description=Jupyter Lab

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/usr/local/bin/jupyter-lab --config=/root/.jupyter/jupyter_notebook_config.py --allow-root
User=root
Group=root
WorkingDirectory=/root
Restart=always
RestartSec=10
#KillMode=mixed

[Install]
WantedBy=multi-user.target

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