jupyterをsystemdに登録してデーモン化

Raspberry Pi 3(Raspbian)にインストールしたjupyterをサービスに常駐させるため、systemdのserviceファイルを書いたのでメモ。

Serviceファイル

  • 実行ユーザ : jupyter:jupyter
  • .jupyterのあるディレクトリ : /home/jupyter

sudo vi /etc/systemd/system/jupyter.service

[Unit]
Desctiption = Jupyter notebook
After = syslog.target

[Service]
Type = simple
WorkingDirectory = /home/jupyter
Restart = always
ExecStart = /usr/local/bin/jupyter notebook
User = jupyter
Group = jupyter

[Install]
WantedBy = multi-user.target

サービス実行、自動起動登録

sudo systemctl start jupyter
sudo systemctl enable jupyter