在EC2 linux(CentOS)上重新启动时自动启动进程

在EC2 linux(CentOS)上重新启动时自动启动进程,linux,amazon-web-services,amazon-ec2,centos,Linux,Amazon Web Services,Amazon Ec2,Centos,我想确保在我的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 initi

我想确保在我的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操作系统, 最简单也是最好的解决方案(尽管使用此解决方案,即使服务器停止,它也会运行,但这不是问题):

  • 转到/etc/init.d
  • 在该目录中创建一个bash脚本(使用
    vim script
    不提供扩展名),并输入如下内容:
  • 现在,在该目录中运行以下命令:

    sudo su
    cd /root/notebooks
    nohup jupyter notebook &
    
    你完了。
    如果您使用的是16.04 ubuntu,请使用更新rc.d

    考虑到Ubuntu操作系统, 最简单也是最好的解决方案(尽管使用此解决方案,即使服务器停止,它也会运行,但这不是问题):

  • 转到/etc/init.d
  • 在该目录中创建一个bash脚本(使用
    vim script
    不提供扩展名),并输入如下内容:
  • 现在,在该目录中运行以下命令:

    sudo su
    cd /root/notebooks
    nohup jupyter notebook &
    
    你完了。
    如果您使用的是16.04 ubuntu,请使用更新rc.d

    @Arturo按照我告诉你的在init.d中创建脚本,然后运行“chkconfig--level 345 scriptname on”@Arturo按照我告诉你的在init.d中创建脚本,然后运行“chkconfig--level 345 scriptname on”