Linux的启动java程序在启动时(EC2实例)启动时、实例、程序、Linux

由网友(岁月枯荣)分享简介:我的服务器程序需要在一个EC2实例启动时启动。在一分钟我只是启动它从我的SSH用下面的命令:my server program needs to be launched on the startup of an EC2 instance. At the minute im just launching it from...

我的服务器程序需要在一个EC2实例启动时启动。在一分钟我只是启动它从我的SSH用下面的命令:

my server program needs to be launched on the startup of an EC2 instance. At the minute im just launching it from my SSH with the following commands:

 java -jar ~/DocumentManager/DocumentServer-0.2.jar  

我尝试添加这样的.bashrc中和的/etc/rc.local文件,但他们似乎只是当我ssh登录工作。

I tried adding this to the .bashrc and /etc/rc.local files but they only seem to work when i ssh in.

任何人都知道如何使它所以我的应用程序的实例启动时,在计算机启动?

Anyone know how to make it so an instance of my application is launched when the computer boots?

谢谢

推荐答案

这是可能的,你可以创建一个脚本 java_server_launch.sh 是这样的:

It's possible you can create a script java_server_launch.sh like this:

 #! /usr/bin/sh

    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
    JAVA=/usr/bin/java
    MY_SERVER=/home/your_username/DocumentManager/DocumentServer-0.2.jar
    USER=your_username
    /bin/su - $USER -c "$JAVA -jar $MY_SERVER &"

把你的脚本/etc/init.d目录下,然后使用命令:

Put your script under /etc/init.d directory, and then use the command:

update-rc.d java_server_launch.sh defaults

更多关于更新-的rc.d 的命令,用男人更新-的rc.d

希望这有助于。

问候。

阅读全文

相关推荐

最新文章