jupyter-lab设置自启动及远程连接开发环境

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

jupyter-lab设置自启动及远程连接开发环境

绝世这天下   2023-03-20 我要评论

1 创建JupyterLab运行脚本

首先找到jupyter-lab命令的位置,一般在~/.local/bin/下,可以创建shell脚本autoJupyterLab.sh:

#!/bin/sh
/home/myjetson/.local/bin/jupyter-lab

测试一下脚本的正确性::

./autoJupyterLab.sh

远程连接JupyterLab成功,说明运行脚本没问题。

2 添加JupyterLab Service文件

Ubuntu18通过systemd管理服务,因此添加服务来开机运行JupyterLab脚本。

服务Service保存在/lib/systemd/system和/etc/systemd/system下。在/etc/systemd/system下创建auto-jupyter.service服务:

[Unit]
Description=Auto Load JupyterLab
After=network.target

[Service]
Type=simple
User=your_username
ExecStart=/your_script_dir/autoJupyterLab.sh
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

3 设置Jupyter Service自启动

让systemd重新加载service文件:

sudo systemctl daemon-reload

然后设置auto-jupyter.service开机自启:

sudo systemctl enable auto-jupyter.service

这样配置就完成了。

4 测试自启动服务

试着手动运行auto-jupyter.service,看看服务写的有没有问题:

sudo systemctl start auto-jupyter.service
sudo systemctl status auto-jupyter.service

重启服务器,远程连接jupyterlab,大功告成!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们