非root用户需要sudo
①创建配置文件
vim /etc/systemd/system/jupyter.service
②编写配置文件
ExecStart=路径/bin/jupyter-lab --config=路径/jupyter_lab_config.py
User=用户名
Group=所属组
WorkingDirectory=工作目录
[Unit]
Description=Jupyterlab
After=network.target
[Service]
Type=simple
ExecStart=路径/bin/jupyter-lab --config=路径/jupyter_lab_config.py
User=用户名
Group=所属组
WorkingDirectory=工作目录
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
③设置开机自启
systemctl enable jupyter (开机自启动)
systemctl start jupyter (启动)
常用
systemctl stop jupyter (停止)
systemctl restart jupyter (重启)