Run jupyter notebook on system boot

I found systemd works really well for me on my Ubuntu server. There are a bunch of ways to do this, but using systemd on Ubuntu you can set up an “always running” jupyter workplace (e.g. a directory with all your projects). Systemd will handle restarting for you after reboots or crashes.

Create the file: /etc/systemd/system/jupyter.service

[Unit]
Description=Jupyter Workplace

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/bfortuner/anaconda3/bin/jupyter-notebook --config=/home/bfortuner/.jupyter/jupyter_notebook_config.py
User=bfortuner
Group=bfortuner
WorkingDirectory=/home/bfortuner/workplace
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Then, run the commands

systemctl enable jupyter.service
systemctl daemon-reload
systemctl restart jupyter.service
2 Likes