Sim*_*yer 6 ubuntu boot startup server jupyter-notebook
我有一个安装了 anaconda 的 Ubuntu 16.04 虚拟机,我希望它在启动时使用正确的配置文件(IP 地址、端口、密码...)启动 Jupyter-notebook
此配置在 /home/user/.jupyter/jupyter_notebook_config.py 中指定
当我以用户身份登录并在主目录 (/home/user/) 中时,它会启动正确的配置文件。
但是当使用命令时
jupyter-notebook
Run Code Online (Sandbox Code Playgroud)
在使用 rc.local 或使用 crontab 启动期间,它不会加载我的配置文件,并且没有正确的运行目录。
非常相似的问答:How to start ipython notebook server at boot as daemon
您可以将以下行添加到您的/etc/rc.local文件中
su <username> -c "jupyter notebook --config=/location/of/your/config/file/.jupyter/jupyter_notebook_config.py --no-browser --notebook-dir=/location/of/yournotebooks" &
Run Code Online (Sandbox Code Playgroud)
例如
su simon -c "jupyter notebook --config=/home/simon/.jupyter/jupyter_notebook_config.py --no-browser --notebook-dir=/home/simon/notebooks" &
Run Code Online (Sandbox Code Playgroud)
su <username> -c 确保笔记本不是以 root 身份执行,而是使用指定的用户帐户执行。``
--config并--notebook-dir指定您的配置文件和笔记本文件夹的位置(http://jupyter-notebook.readthedocs.io/en/latest/config.html)
对于使用systemd(Ubuntu 16 及更高版本)的系统,以下方法也适用:
在 中创建一个服务文件/etc/systemd/system/,例如jupyter.service使用以下内容(替换YourUserName为您的用户名)
[Unit]
After=network.service
[Service]
ExecStart=jupyter notebook
User=YourUserName
[Install]
WantedBy=default.target
Run Code Online (Sandbox Code Playgroud)启用服务 sudo systemctl enable jupyter.service
sudo systemctl start jupyter.service您应该为 Jupyter 服务器设置密码,因为您将无法访问令牌。