Jupyter作为服务实现开机自启
安装jupyter
pip install jupyter
生成jupyter的配置文件
jupyter notebook --generate-config
配置参数
- 常用参数
## 公网访问的设置以下参数
c.NotebookApp.certfile = '' # 证书文件
c.NotebookApp.keyfile = '' # 私钥文件
c.NotebookApp.ip = '' # 允许访问的IP地址
c.NotebookApp.password = PASSWORD # 设置访问密码,hash值,可以使用python导入'from notebook.auth import passwd; passwd()'利用这个函数生成
## 内网或者只在本机访问的参数
c.NotebookApp.port = 28888 # 运行端口
c.NotebookApp.open_browser = False # 运行 notebook 应用时不打开浏览器
c.NotebookApp.notebook_dir = DIR # 设置notebook文件的存放目录
添加unit文件
[Unit]
Description=Jupyter
After=syslog.target network.target
[Service]
User=hxjq
Environment= 替换自己的环境变量
ExecStart=/home/hxjq/.local/bin/jupyter notebook # 替换成自己jupyter命令的路径
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
设置开机自启
systemctl daemon-reload
systemctl enable jupyter
systemctl start jupyter
© 著作权归作者所有
文章评论(0)