简体   繁体   English

在EC2 Linux(CentOS)上重新启动时自动启动过程

[英]Start process automatically at reboot on EC2 linux (CentOS)

I want to make sure that a web service starts automatically when my AWS EC2 Linux machine is rebooted. 我想确保在重启我的AWS EC2 Linux计算机时自动启动Web服务。

To start manually the process I need to type the following commands: 要手动启动该过程,我需要输入以下命令:

sudo su
cd /root/notebooks
nohup jupyter notebook &

I edited the /etc/rc.local as per below, but the process never starts. 我按照以下内容编辑了/etc/rc.local,但是该过程从未开始。 Any ideas? 有任何想法吗?

#
# 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

Answering considering Ubuntu OS, The easiest and the best solution (though with this it will run even when the server is stopping, but that is not an issue here): 考虑到Ubuntu OS,最简单,最好的解决方案(尽管这样,即使服务器停止运行,它也可以运行,但这不是问题):

  1. Go to /etc/init.d 转到/etc/init.d
  2. Create a bash script (using vim script don't give an extension) in that directory and enter the content as follows: 在该目录中创建一个bash脚本(使用vim script不提供扩展名),并按如下所示输入内容:
 sudo su cd /root/notebooks nohup jupyter notebook & 

Now, within that directory itself, run the following commands: 现在,在该目录本身中,运行以下命令:

 chmod +x script update-rc script defaults 

You're done. 你完成了。 If you're using 16.04 ubuntu, use update-rc.d. 如果您使用的是16.04 ubuntu,请使用update-rc.d。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM