linux:设置tomcat开机自动启动
2014-02-10 18:42
459 查看
tomcat做服务器在windows下开机自动运行
要启动scim(某一程序),我们首先要知道scim程序在哪里,用locate命令可以找到,scim在/usr/bin/scim这里,其中usr表 示是 属于用户的,bin在linux里表示可以执行的程序。这样,我就可以编写一个脚本程序,把它放到/etc/init.d里,然后在rc5.d里做一个相 应的软链接就可以了。
这个脚本其实很简单,就两行:
#!/bin/bash
/usr/bin/scim
linux:设置tomcat开机自动启动
分公司的一台服务器,重新启动后,老是忘记启动tomcat, 开发的同事要求设置为开机自动启动,感觉很简单,但还是花了点时间修改才完成。
新建touch .tomcatd
复制 tomcatd
到 /etc/init.d
参考了网上的几个帖子,但都不是很适合要求,还是要自己修改一下,大概如下:
[root@appsit init.d]#
/etc/init.d
[root@appsit init.d]# cat tomcatd
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
RETVAL=0
# CATALINA_HOME="/usr/apps/apache/tomcat/jakarta-tomcat-4.0.4"
export JAVA_HOME=/tomcat/java/jdk1.5.0_09
export CATALINA_HOME=/tomcat/tomcat/apache-tomcat-5.5.20
export CATALINA_BASE=/tomcat/tomcat/apache-tomcat-5.5.20
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu tomcat | grep apache-tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
[root@appsit init.d]# chmod u+x tomcatd
[root@appsit init.d]# chkconfig --add tomcatd
[root@appsit init.d]# chkconfig --list tomcatd
tomcatd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@appsit init.d]# service tomcatd stop
删除:
[root@appsit init.d]# chkconfig --del tomcatd
执行chkconfig tomcat on。 自启动
service tomcatd stop/start
模板:
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
#source /etc/sysconfig/rc
#source $rc_functions
case "$1" in
start)
echo "Starting Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus start
;;
stop)
echo "Stopping Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus stop
;;
restart)
echo "Restarting Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus restart
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
6. 关于开机程序的自动启动
系统脚本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d链接,也可以直接放置在/etc/rc.d/rc.local中。
init.d脚本包含完整的start,stop,status,reload等参数,是标准做法,推荐使用。
为特定用户使用的程序(如有的用户需要使用中文输入法而有的不需要)放置在~/中的bash启动脚本中。
要启动scim(某一程序),我们首先要知道scim程序在哪里,用locate命令可以找到,scim在/usr/bin/scim这里,其中usr表 示是 属于用户的,bin在linux里表示可以执行的程序。这样,我就可以编写一个脚本程序,把它放到/etc/init.d里,然后在rc5.d里做一个相 应的软链接就可以了。
这个脚本其实很简单,就两行:
#!/bin/bash
/usr/bin/scim
linux:设置tomcat开机自动启动
分公司的一台服务器,重新启动后,老是忘记启动tomcat, 开发的同事要求设置为开机自动启动,感觉很简单,但还是花了点时间修改才完成。
新建touch .tomcatd
复制 tomcatd
到 /etc/init.d
参考了网上的几个帖子,但都不是很适合要求,还是要自己修改一下,大概如下:
[root@appsit init.d]#
/etc/init.d
[root@appsit init.d]# cat tomcatd
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
RETVAL=0
# CATALINA_HOME="/usr/apps/apache/tomcat/jakarta-tomcat-4.0.4"
export JAVA_HOME=/tomcat/java/jdk1.5.0_09
export CATALINA_HOME=/tomcat/tomcat/apache-tomcat-5.5.20
export CATALINA_BASE=/tomcat/tomcat/apache-tomcat-5.5.20
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu tomcat | grep apache-tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
[root@appsit init.d]# chmod u+x tomcatd
[root@appsit init.d]# chkconfig --add tomcatd
[root@appsit init.d]# chkconfig --list tomcatd
tomcatd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@appsit init.d]# service tomcatd stop
删除:
[root@appsit init.d]# chkconfig --del tomcatd
执行chkconfig tomcat on。 自启动
service tomcatd stop/start
模板:
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
#source /etc/sysconfig/rc
#source $rc_functions
case "$1" in
start)
echo "Starting Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus start
;;
stop)
echo "Stopping Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus stop
;;
restart)
echo "Restarting Apache daemon..."
/root/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2-bundle/nexus-oss-webapp-1.7.2/bin/jsw/linux-x86-32/nexus restart
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
6. 关于开机程序的自动启动
系统脚本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d链接,也可以直接放置在/etc/rc.d/rc.local中。
init.d脚本包含完整的start,stop,status,reload等参数,是标准做法,推荐使用。
为特定用户使用的程序(如有的用户需要使用中文输入法而有的不需要)放置在~/中的bash启动脚本中。
相关文章推荐
- linux:设置tomcat开机自动启动
- 设置linux开机自动启动Tomcat
- linux设置tomcat开机自动启动
- linux设置tomcat开机自动启动
- linux设置tomcat开机自动启动
- 使用Java Service Wrapper设置tomcat作为linux服务并且开机自动启动
- linux设置tomcat开机自动启动
- Linux下设置Tomcat开机自动启动
- 使用Java Service Wrapper设置tomcat作为linux服务并且开机自动启动
- linux设置开机服务自动启动/关闭自动启动命令
- Linux:设置Tomcat开机启动
- Linux设置程序开机启动-tomcat开机启动
- linux设置网卡开机自动启动
- Linux(CentOS)下设置nginx开机自动启动和chkconfig管理
- 在linux下设置开机自动启动程序的方法(一)
- Linux下Tomcat开机自动启动
- Linux开机自动启动ORACLE设置
- Linux(CentOS)下设置nginx开机自动启动和chkconfig管理
- linux设置开机服务自动启动/关闭自动启动命令
- linux添加tomcat服务并设置开机启动