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 $*