重启tomcat脚本 川长思鸟来 2022-04-10 08:12 491阅读 0赞 [python]重启tomcat脚本,写的不好[复制链接] 电梯直达 1# 发表于 2011-9-21 16:07:01 | 只看该作者 | 倒序浏览 本帖最后由 envfull 于 2011-9-21 16:07 编辑 #!/usr/bin/env python #--coding=utf-8-- “”” 1.自动启动tomcat ;2.自动关闭tomcat ;3.自动重tomcat ; “”” import os import sys import time import glob import telnetlib host = “127.0.0.1” port = “80” tomcat = “/var/apache-tomcat-6.0.18/“ #tomcat路径 #清空tomcat所有日志 def clearlog(): os.system(“cat “ + “/dev/null “ + “> “ + tomcat + “logs/catalina.out”) map(os.remove, glob.glob(tomcat + “logs/.log”)) map(os.remove, glob.glob(tomcat + “logs/.txt”)) #关闭tomcat服务器————————————————————————————— def shutdown(): clearlog() print “tomcat正在关闭,请等13秒。。。” os.system(tomcat + “bin/shutdown.sh”) os.system(“kill -9 ps -ef | grep java| awk '{print $2}'“) time.sleep(13) try: tel = telnetlib.Telnet(host, port) print “关闭tomcat失败,请手动关闭” sys.exit() except: print “关闭tomcat成功” #启动tomcat服务器————————————————————————————— def startup(): clearlog() print “tomcat正在启动,广告过后,马上回来。。。” os.system(tomcat + “bin/startup.sh”) time.sleep(3) for k in range(38, 0, -1): print k time.sleep(1) os.system(“clear”) #判断是否启动成功 rizhi = open(tomcat + “logs/catalina.out”, ‘r’) try: telnet = telnetlib.Telnet(host, port) xinxi = rizhi.read() xinxi.index(“Server startup in”) print “让你久等了,5秒后揭晓答案” time.sleep(6) print “启动tomcat成功,这次算你运气好!” rizhi.close() except: print “启动tomcat失败,其实早在我预料之内!” rizhi.close() #重启tomcat服务器————————————————————————————— def chongqi(): os.system(“service mysql restart”) print “哈哈,数据库重启成功,6秒后重启tomcat!” time.sleep(6) #关闭tomcat shutdown() #启动tomcat startup() #查看或搜索tomcat日志——————————————————————————- def viewlog(): if sousuo == “”: os.system(“cat “ + tomcat + “logs/catalina.out”) else: os.system(“grep -n “ + sousuo + “ “ + tomcat + “logs/catalina.out”) #—————————————————————————————- def main(): print “|—————————————————————————————————————|\n\ 欢迎使用rmao!\n\ rmao st #启动tomcat服务器\n\ rmao sh #关闭tomcat服务器\n\ rmao r #重启tomcat服务器\n\ rmao l #查看tomcat日志\n\ rmao c #清空tomcat日志\n\ \n\ rmao l startup #在catalina.out中查找 startup 这个关键字\n\ \n\ |—————————————————————————————————————|\n “ os.system(“netstat -tnlp”) print “———————————————————————————————————-“ os.system(“df -h”) print “———————————————————————————————————-“ if name == “main“: if len(sys.argv) < 2: main() sys.exit() else: pass tihuan = sys.argv[1] sousuo = “” if len(sys.argv) == 3: sousuo = sys.argv[2] if tihuan == “r”: chongqi() elif tihuan == “st”: startup() elif tihuan == “sh”: shutdown() elif tihuan == “l”: viewlog() elif tihuan == “c”: clearlog() else: main() sys.exit()
相关 tomcat自动重启脚本 tomcat自动重启的linux 脚本 !/bin/bash tomcat_is_alive=`ps -ef| grep "java" | grep 怼烎@/ 2023年07月25日 06:29/ 0 赞/ 51 阅读
相关 Linux下tomcat重启shell脚本 1、使用说明 存放目录tomcat/bin目录下,即可适用于任何目录下的tomcat,并且重启只针对当前目录的下的tomcat有效。 可命名为restart.sh 红太狼/ 2023年02月18日 09:49/ 0 赞/ 176 阅读
相关 Linux重启脚本 1. 上传jar到package目录,提前完成; 2. 重命名之前的文件jar\dir; 3. 移动解压上传的包; 4. 编辑上传的脚本 素颜马尾好姑娘i/ 2022年12月11日 09:11/ 0 赞/ 410 阅读
相关 重启脚本 !/bin/sh echo "Current DIR is " $PWD stillRunning=$(ps -ef |grep "$PWD" |gr 忘是亡心i/ 2022年08月19日 12:26/ 0 赞/ 438 阅读
相关 tomcat重启 在Linux系统下,重启Tomcat使用命令操作的! 1、首先,进入Tomcat下的bin目录 <table style="border-spacing:0px;borde 悠悠/ 2022年05月29日 09:22/ 0 赞/ 455 阅读
相关 重启tomcat脚本 [\[python\]][python][重启tomcat脚本,写的不好][tomcat][\[复制链接\]][tomcat] <table> <tbody> 川长思鸟来/ 2022年04月10日 08:12/ 0 赞/ 492 阅读
相关 利用linux shell脚本 重启tomcat 在工作中遇到要使用ps -ef | grep tomcat6 来进程ID并kill掉后重启tomcat的场景 killRestart.sh =============== 川长思鸟来/ 2022年03月15日 14:44/ 0 赞/ 548 阅读
相关 Shell 脚本 —— java 代码远程调用shell脚本重启 tomcat 个人博客网:[https://wushaopei.github.io/][https_wushaopei.github.io] (你想要这里多有) 1、创建mav 以你之姓@/ 2022年02月09日 07:56/ 0 赞/ 633 阅读
相关 tomcat假死重启脚本 最近几天老是出现tomcat假死的情况,主要表现为,进程还在,但是tomcat不再提供任何服务,并且日志也停止记录。 因为暂时无法定位原因,所以先采用临时的解决方案,服务器上 迷南。/ 2022年01月23日 03:47/ 0 赞/ 533 阅读
相关 LINUX tomcat重启shell脚本 > 出于各种原因tomcat需要重启,这里把脚本添加到crontab中,设置定时任务进行重启 脚本1(把脚本添加到`crontab`中执行): 傷城~/ 2021年12月22日 05:45/ 0 赞/ 577 阅读
还没有评论,来说两句吧...