将tomcat注册为服务linux
2011-07-06 13:55
399 查看
1.在/etc/rc.d/init.d中建tomcat脚本.
2.chkconfig --add tomcat就可以用service tomcat start/stop/rstart了
附:脚本(我也是抄的,呵呵)
#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>;
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between Red Hat Tomcat RPM and Chris Bush scripts
# Tomcat name :)
TOMCAT_PROG=tomcat
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
TOMCAT_USER="tomcat"
fi
RETVAL=0
# start and stop functions
start() {
echo -n "Starting tomcat: "
chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/jakarta-tomcat/*
chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat/bin/startup.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
return $RETVAL
}
stop() {
echo -n "Stopping tomcat: "
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat/bin/shutdown.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
rm -rf /usr/local/jakarta-tomcat/work/*
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
# Ugly hack
# We should really make sure tomcat
# is stopped before leaving stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
2.chkconfig --add tomcat就可以用service tomcat start/stop/rstart了
附:脚本(我也是抄的,呵呵)
#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>;
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between Red Hat Tomcat RPM and Chris Bush scripts
# Tomcat name :)
TOMCAT_PROG=tomcat
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
TOMCAT_USER="tomcat"
fi
RETVAL=0
# start and stop functions
start() {
echo -n "Starting tomcat: "
chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/jakarta-tomcat/*
chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat/bin/startup.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
return $RETVAL
}
stop() {
echo -n "Stopping tomcat: "
su -l $TOMCAT_USER -c '/usr/local/jakarta-tomcat/bin/shutdown.sh'
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
rm -rf /usr/local/jakarta-tomcat/work/*
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
# Ugly hack
# We should really make sure tomcat
# is stopped before leaving stop
sleep 2
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
相关文章推荐
- Linux注册tomcat服务
- Linux注册tomcat为服务
- windows和linux 下将tomcat注册为服务
- windows和linux 下将tomcat注册为服务
- linux 下将tomcat注册成服务并开机启动
- Linux之tomcat服务注册
- 【tomcat】linux下将tomcat注册到系统服务中
- Linux下tomcat注册成服务
- Linux(Debian) 上安装tomcat并注册服务开机自启动
- windows和linux 下将tomcat注册为服务
- Linux注册tomcat为服务
- tomcat 在windows中注册和删除服务
- linux下简单的tomcat服务监测程序
- 在Linux下面实现QDbus通信机制服务对象注册失败
- 将应用注册为Linux的服务
- Tomcat 免安装版注册为系统服务
- Linux下三行指令将Tomcat配置成服务及自启动
- 如何Tomcat注册成系统服务
- 如何将tomcat启动注册为系统服务
- Linux运行两个tomcat服务