Linux start-up script for java application

前端 未结 6 930
醉梦人生
醉梦人生 2021-01-07 11:31

I have Jar file to run in Linux using this command:

java -jar SyslogAgent_01.jar 192.168.2.154 1998 D:/apachelog.log ApacheLog 13

Can anyon

6条回答
  •  别那么骄傲
    2021-01-07 12:06

    Basically, you need to create a little shell script in /etc/init.d and make symlinks to /etc/rc2.d and /etc/rc5.d. The contents could be like this:

    #!/bin/sh
    if [ "$1" = start ] ; then
        cd /put_your_workdir_here
        /usr/bin/java -jar SyslogAgent_01.jar 192.168.2.154 1998 D:/apachelog.log ApacheLog 13 &
    fi
    

    Notice that you start your program in background (& at the end of the commandline)

提交回复
热议问题