Linux下Jupyter开机启动设置

您所在的位置:网站首页 今晚的中超直播广州队 Linux下Jupyter开机启动设置

Linux下Jupyter开机启动设置

2023-08-30 05:26| 来源: 网络整理| 查看: 265

写在前面

  由于平时经常使用Jupyter,于是在Linux上设置了开机启动,网上找了些常用的方法,此贴记录了操作过程,尝试了3种方法,对于没有成功的2种方法后续进行跟进和更新。

  为了方便查看启动情况,将操作日志写到了jupyter_notebook的目录下。

方法1:rc.local(未生效)

  编写开机启动脚本:

vim /home/jupyter.sh ######################################################## #!/bin/bash /bin/echo $(/bin/date +%F %T) >> /home/startup.log # jupyter nohup jupyter notebook > /home/jupyter_notebook/jupyter.log & ########################################################

  配置开机启动:

$ ll /etc/rc.local lrwxrwxrwx. 1 root root 13 Feb 5 10:03 /etc/rc.local -> rc.d/rc.local $ tail -n 1 /etc/rc.local /bin/bash /home/jupyter.sh >/dev/null 2>/dev/null 方法2:chkconfig(未生效)

  编写开机启动脚本:

$ vim /etc/init.d/jupyter.sh #!/bin/sh #chkconfig: 35 20 80 分别代表运行级别,启动优先权,关闭优先权 #description: http server /bin/echo $(/bin/date +%F_%T) >> /home/startup.log nohup jupyter notebook > /home/jupyter_notebook/jupyter.log & $ chmod +x /etc/init.d/jupyter.sh

  添加脚本到开机自动启动项目中,添加到chkconfig,开机自启动。

$ cd /etc/init.d $ chkconfig --add jupyter.sh $ chkconfig jupyter.sh on ## 关闭开机启动 $ chkconfig jupyter.sh off 方法3:systemctl(成功)

  编写启动脚本:

$ vim /opt/jupyter.sh #!/bin/sh /bin/echo $(/bin/date +%F_%T) >> /home/startup.log /root/anaconda3/bin/jupyter notebook > /home/jupyter_notebook/jupyter.log

  添加启动服务:

$ vim /etc/systemd/system/jupyter.service [Unit] Description=jupyter.sh After=network.target [Service] Type=simple ExecStart=/opt/jupyter.sh ExecReload=/bin/kill -s HUP $MAINPID RestartSec=2s Restart=on-failure [Install] WantedBy=multi-user.target

  服务操作命令:

## 查看服务状态 $ systemctl status jupyter.service ## 启动服务 $ systemctl start jupyter.service ## 设置开机自启动 $ systemctl enable jupyter.service ## 取消开机自启动 $ systemctl disable jupyter.service


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3