generate config
| 12
 
 | jupyter notebook --generate-configecho "c.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py
 
 | 
activate service 开机自启
| 1
 | vim /etc/systemd/system/jupyter.service
 | 
添加如下代码,并保存
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | [Unit]Description=Jupyter Notebook
 After=network.target
 [Service]
 Type=simple
 ExecStart=/home/jinzhongxu/miniconda3/bin/jupyter-lab --config=/home/jinzhongxu/.jupyter/jupyter_notebook_config.py --no-browser
 User=jinzhongxu
 Group=jinzhongxu
 WorkingDirectory=/home/jinzhongxu/
 Restart=always
 RestartSec=10
 [Install]
 WantedBy=multi-user.target
 
 | 
enable jupyter
| 12
 
 | systemctl enable jupytersystemctl start jupyter
 
 | 
其他程序或服务,也可以使用上面的方法,需要注意两点:
- 系统版本不能太低,如 Ubuntu 14.04等,因为该系统没有 systemd
- jupyter.service 中的 ExecStart 后面的命令不能使用 ~jinzhongxu,必须使用绝对路径
一个例子:
| 1
 | vim /etc/systemd/system/frpc.service
 | 
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | [Unit]Description=frpc daemon
 After=network.target
 
 [Service]
 Type=simple
 ExecStart=/home/jinzhongxu/.frp.local/frpc -c /home/jinzhongxu/.frp.local/frpc.ini
 #ExecStart=/home/jinzhongxu/.frp.local/frp
 # nohup /home/jinzhongxu/.frp.local/frpc -c /home/jinzhongxu/.frp.local/frpc.ini > log &
 User=jinzhongxu
 Group=jinzhongxu
 WorkingDirectory=/home/jinzhongxu/.frp.local/
 Restart=always
 RestartSec=10
 
 [Install]
 WantedBy=multi-user.target
 
 | 
| 12
 
 | sudo systemctl start frpc.servicesudo systemctl enable frpc.service
 
 |