我想确保在我的 AWS EC2 Linux 机器重新启动时自动启动 Web 服务。
要手动启动该过程,我需要键入以下命令:
sudo su
cd /root/notebooks
nohup jupyter notebook &
我按如下方式编辑了/etc/rc.local,但该过程从未开始。有什么想法吗?
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
sudo su
cd /root/notebooks
nohup jupyter notebook &
touch /var/lock/subsys/local
考虑到 Ubuntu OS 的回答,最简单和最好的解决方案(尽管即使服务器停止,它也会运行,但这不是问题):
- 转到/etc/init.d
- 在该目录中创建一个 bash 脚本(使用
vim script
不给出扩展名)并输入内容,如下所示:
sudo su cd /root/notebooks nohup jupyter notebook &
现在,在该目录本身中,运行以下命令:
chmod +x script update-rc script defaults
大功告成。如果您使用的是 16.04 ubuntu,请使用 update-rc.d。