日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

linux:設置tomcat開機自動啟動

系統(tǒng) 2261 0
?
2008/2/5

linux:設置tomcat開機自動啟動

????分公司的一臺服務器,重新啟動后,老是忘記啟動tomcat, 開發(fā)的同事要求設置為開機自動啟動,感覺很簡單,但還是花了點時間修改才完成。
 參考了網(wǎng)上的幾個帖子,但都不是很適合要求,還是要自己修改一下,大概如下:
[root@appsit init.d]# pwd
/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
TOMCATUSER=tomcat
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
?
寫得也還不完善,比如tomcat 用戶用個變量代替,用 RETVAL=$?來返回最后命令的退出狀態(tài),...
這些留待以后完善

linux:設置tomcat開機自動啟動


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 宜川县| 凤庆县| 辽阳县| 永兴县| 石台县| 涪陵区| 博兴县| 崇州市| 北流市| 定结县| 错那县| 甘南县| 宝丰县| 泗洪县| 西畴县| 漳浦县| 吉林市| 成安县| 上思县| 云霄县| 开封县| 沈阳市| 柳州市| 建阳市| 八宿县| 崇仁县| 车险| 荆门市| 峨山| 海宁市| 陆良县| 阿合奇县| 天津市| 通州市| 恩施市| 称多县| 高台县| 深水埗区| 新巴尔虎左旗| 莱芜市| 农安县|