최대 1 분 소요

 안녕하세요 마개입니다.
Jupyter Notebook을 설치 완료하고 백그라운드 실행을 완료하였다면 서비스를 등록하여 서버가 재가동되더라도 실행되도록 해봅니다.


image



service 생성

Ubuntu 환경에서 진행을 하고 여기서는 service 파일을 생성해서 진행해봅니다.


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


1
2
3
4
5
6
7
8
9
10
11
12
[Unit]
Description=Jupyter Notebook Server

[Service]
Type=simple
PIDFile=/run/jupyter.pid
User=root
ExecStart=/root/anaconda3/bin/jupyter-notebook
WorkingDirectory=/home/hacdev/hacademy

[Install]
WantedBy=multi-user.target

여기에서 기존에 설정한 config 파일 내용대로 하고 싶다면 아래와 같이 수정합니다.여기서 UserExecStart의 root는 개인별로 jupyter notebook이 설치되어있는 위치로 변경합니다.


1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=Jupyter Notebook Server

[Service]
Type=simple
PIDFile=/run/jupyter.pid
User=root
ExecStart=/root/anaconda3/bin/jupyter-notebook --allow-root --config /root/.jupyter/jupyter_notebook_config.py

[Install]
WantedBy=multi-user.target



service 등록

위와 같이 service를 생성했다면 이를 등록합니다.

1
2
3
systemctl daemon-reload
systemctl enable jupyter.service
systemctl start jupyter.service



확인

image

웹 브라우저를 통해 비밀번호를 넣고 잘 들어가는지 확인해봅니다.