Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3436830
  • 博文数量: 864
  • 博客积分: 14125
  • 博客等级: 上将
  • 技术积分: 10634
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 16:53
个人简介

https://github.com/zytc2009/BigTeam_learning

文章分类

全部博文(864)

文章存档

2023年(1)

2021年(1)

2019年(3)

2018年(1)

2017年(10)

2015年(3)

2014年(8)

2013年(3)

2012年(69)

2011年(103)

2010年(357)

2009年(283)

2008年(22)

分类:

2010-10-12 09:36:10

1、 将该文件放在 /etc/init.d目录下,以后就可以使用service tomcat start/stop/status/restart等命令了

2、 在/etc/rc.d/rc3.d目录下,执行 ln –s /etc/init.d/tomcat /etc/rc.d/rc3.d/S99tomcat
这样,开机就会自动启动Tomcat了。

3.如果不能运行,请检查
chmod 755 /etc/init.d/tomcat
chmod 755 apache-tomcat-5.5.25/
vi /etc/passwd
修改启动用户如
apache 的/sbin/nologin 为/bin/bash

4、 脚本
#!/bin/sh
#
# Start staff.macaufly.net webserver
# Currently installed under /home/jira and should moved to /home/tomcat later
#

TOMCAT_BIN=/home/tomcat6/bin
TOMCAT_USER=apache

start() {

stop
su - $TOMCAT_USER -c $TOMCAT_BIN/startup.sh
sleep 10
if netstat -an | grep 8080 >/dev/null
then
echo "Tomcat is running"
return 0
else
return 1
fi
}

stop() {
if netstat -an | grep 8080 | grep LISTEN >/dev/null
then
# try to shutdown the server first
echo "Now Shutdown the server..."
su - $TOMCAT_USER -c  $TOMCAT_BIN/shutdown.sh
else
echo "Tomcat is not running"
return 0
fi

if netstat -an | grep 8080 | grep LISTEN
then
sleep 10
echo "Now kill it"
ps -ef | grep java | grep $TOMCAT_USER | awk '{print "kill -9 ", $2;}' | sh
fi

if netstat -an | grep 8080 | grep LISTEN >/dev/null
then
return 1 # still alive
else
echo "Tomcat is stopped"
return 0
fi
}

case "$1" in
  start)
start
;;

  stop)
stop
;;

  restart)
start
;;

  status)
  if netstat -an |grep 8080|grep LISTEN >/dev/null
then
echo "Tomcat is Running"
else
echo "Tomcat is Not Running"
fi
;;

  *)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac

exit 0
阅读(993) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~