Linux下简单的tomcat管理脚本
来源:互联网 发布:landmark软件安装 编辑:程序博客网 时间:2024/05/17 02:05
现在使用Linux作为项目运行环境的已经越来越多,Linux下tomcat启动默认是看不到输出信息的,如日常开发中可以在eclipse中看到的输出信息都被输出到logs/catalina.out.需要查看的话可以使用
tail -f logs/catalina.out
笔者经常需要发布项目新版本,需要不断操作tomcat启动和关闭。于是写了以下tomcat.py的Python脚本:
# encoding:utf-8import os, sysstart_operation = ['startup', '-startup', '--startup', 'start', '-start', '--start']stop_operation = ['shutdown', '-shutdown', '--shutdown', 'stop', '-stop', '--stop']show_operation = ['show', 'log']def show_help(): print 'usage: python tomcat.py start|stop|show' print '\n\n' print 'startup operation : ' print start_operation print '----------------------------' print 'stop operation : ' print stop_operation print '----------------------------' print 'show operation :' print show_operation print '----------------------------'if __name__=="__main__": operation = '' try: operation = sys.argv[1] except: show_help() sys.exit(0) if operation in start_operation: # start tomcat os.system('/opt/apache-tomcat-8.0.32/bin/shutdown.sh') os.system('/opt/apache-tomcat-8.0.32/bin/startup.sh') os.system('tail -f /opt/apache-tomcat-8.0.32/logs/catalina.out') elif operation in stop_operation: # stop tomcat os.system('/opt/apache-tomcat-8.0.32/bin/shutdown.sh') os.system('tail -f /opt/apache-tomcat-8.0.32/logs/catalina.out') elif operation in show_operation: os.system('tail -f /opt/apache-tomcat-8.0.32/logs/catalina.out') else: show_help() sys.exit(0)
注释一下:
- show_help()是在没有输入指令的时候进行输出显示用法的函数。
- 一共有三种操作,start,stop,show.为了满足不同的习惯,每种操作有各种开关习惯。(感觉这里确实用得有点麻烦,顺便给出一种读取开关指令并控制操作的方法。)
- os.system()就是通过python调用操作系统中的指令。
0 0
- Linux下简单的tomcat管理脚本
- Linux下启动tomcat的脚本文件
- linux下管理ssh的脚本程序
- Linux下管理Tomcat
- Linux下收集日志的简单脚本
- Linux下简单Shell 脚本的写法
- 简单的linux下shell启动脚本
- linux下制作简单的脚本
- linux下tomcat init脚本
- linux下tomcat发布脚本
- 【Git】Linux下的Git简单管理
- Linux下强制杀Tomcat进程的Shell脚本
- linux下每周备份tomcat日志的shell脚本
- Linux系统下用命令快捷启动tomcat的脚本
- linux下tomcat监控自启动脚本
- linux下设置tomcat脚本启动
- linux下设置tomcat脚本启动
- linux下快速启动tomcat脚本
- eclipse-spark开发环境
- 花生棒使用方法图文教程
- 将一个字符串按照最大值最小值连续排列
- 多文件上传(input标签file)
- 解决方案java compiler level does not match the version of the installed java project facet
- Linux下简单的tomcat管理脚本
- 剑指offer|顺时针打印矩阵
- android笔记之关于java.lang.IllegalArgumentException: View not attached to window manager 错误的分析
- Xcode The ‘in-app purchase’ feature is only available to users enrolled in apple developer program
- 链表操作(C++)
- 开发过程
- smarty在普通php页面使用流程
- Java Web中的EL(表达式语言)详解
- C语言多线程