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

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,大功告成!

作者:绝世这天下原文地址:https://blog.csdn.net/weixin_52201738/article/details/128901779

%s 个评论

要回复文章请先登录注册