ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 开机自动启动应用程序 ON Linux

开机自动启动应用程序 ON Linux

原创 Linux操作系统 作者:zhanglei_itput 时间:2010-05-21 15:22:53 0 删除 编辑

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

相关连接:http://space.itpub.net/9252210/viewspace-662886

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9252210/viewspace-663335/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-10

  • 博文量
    400
  • 访问量
    1224632