linux开机自动运行java程序_开机自动启动应用程序 ON Linux

Linux平台开机自动启动resin脚本

之前写过开机自动启动oracle的脚本,但是应用程序不熟悉,也没写过,现在有这个需求,所以就把oracle开机自动启的改吧改吧,还真可以用~~呵呵

1. 创建启动脚本/etc/init.d/tomcat

# chmod +x /etc/init.d/tomcat[root@htjcoa init.d]# more /etc/init.d/tomcat

#!/bin/bash

# Tomcat init script. for Linux.

#

# chkconfig: 345 99 10

# description: Tomcat Automatic Startup on Linux

TOMCAT_OWNER=budget

TOMCAT_HOME=/home/budget/resin

JAVA_HOME=/home/budget/jdk1.5.0_20

case "$1" in

start)

echo "-------------------------------------------------" >> /var/log/tomcat

date +" %T %a %D : Starting Tomcat Application......" >> /var/log/tomcat

su - $TOMCAT_OWNER -c "$TOMCAT_HOME/bin/httpd.sh >/home/budget/resin/log.log" >> /var/log/tomcat

echo "Done."

echo "-------------------------------------------------" >> /var/log/tomcat

touch /var/lock/subsys/budget

;;

*)

echo "Usage: tomcat {start|stop|restart}"

exit 1

esac

2. 开机自动启动

# chkconfig tomcat on

开机关闭自动启动

# chkconfig tomcat off

3. more httpd.sh

[budget@htjcoa bin]$ more httpd.sh

#! /bin/sh

#

# See contrib/init.resin for /etc/rc.d/init.d startup script

#

# resin.sh can be called like apachectl

#

# resin.sh         -- execs resin in the foreground

# resin.sh start   -- starts resin in the background

# resin.sh stop    -- stops resin

# resin.sh restart -- restarts resin

#

# resin.sh will return a status code if the wrapper detects an error, but

# some errors, like bind exceptions or Java errors, are not detected.

#

# To install, you'll need to configure JAVA_HOME and RESIN_HOME and

# copy contrib/init.resin to /etc/rc.d/init.d/resin.  Then

# use "unix# /sbin/chkconfig resin on"

if test -n "${JAVA_HOME}"; then

if test -z "${JAVA_EXE}"; then

JAVA_EXE=$JAVA_HOME/bin/java

fi

fi

#

# trace script. and simlinks to find the wrapper

#

if test -z "${RESIN_HOME}"; then

script=`/bin/ls -l $0 | awk '{ print $NF; }'`

while test -h "$script"

do

script=`/bin/ls -l $script. awk '{ print $NF; }'`

done

bin=`dirname $script`

RESIN_HOME="$bin/.."

fi

exec $JAVA_EXE -jar ${RESIN_HOME}/lib/resin.jar $*

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值