快速查看日志脚本

实现脚本之前,需切换到指定目录,再查看日志文件,前提是要求操作者需记住每个程序包或者控制台的路径,否则还得打开环境清单一个个复制路径。。。操作截图以及logs.sh脚本如下:

 1 #!/bin/bash
 2 echo -e "33[33m 请输入需要查看的日志 33[0m"                                                                       #echo命令输出字符串,使用-e参数进行换行
 3 echo -e "33[33m 1.weblogic     2.申办接口     3.网关接口     4.nginx的access日志     5.nginx的error日志33[0m"
 4 echo -e "33[33m 6.窗口一体化接口     7.政务认证接口    33[0m" 
 5 echo -e "33[33m ------------------------------------------- 33[0m"
 6 read type                                                                                                          #定义变量type,接收从键盘输入的值
 7 if [ $type == 1 ] ; then                                                                                           #使用$符合引用变量,根据变量的值执行对应脚本
 8         tail -f -n 5000 /u01/weblogic/Middleware/user_projects/domains/base_domain/bin/nohup.out                   #查看控制台日志。-f为循环(不断刷新)读取文件,-n <行数> 表示显示文件尾部n行内容
 9 elif [ $type == 2 ] ; then
10         tail -f -n 5000 /u01/SBJK/CommonService.log                                                                #查看申办接口日志
11 elif [ $type == 3 ] ; then
12         tail -f -n 5000 /u01/ZWWG/nohup.out                                                                        #查看网关日志
13 elif [ $type == 4 ] ; then
14         tail -f -n 5000 /usr/local/nginx/logs/access.log                                                           #查看nginx的access日志
15 elif [ $type == 5 ] ; then
16         tail -f -n 5000 /usr/local/nginx/logs/error.log                                                            #查看nginx的error日志
17 elif [ $type == 6 ] ; then
18         tail -f -n 5000 /u01/CKYTHJK/log.log                                                                       #查看窗口一体化日志                                                                       
19 elif [ $type == 7 ] ; then
20         tail -f -n 5000 /u01/ZWRZ/nohup.out                                                                        #查看政务认证接口日志
21 else
22         echo "您的输入有误,请正确输入" 
23 fi
24 
25 ~    
原文地址:https://www.cnblogs.com/dnjiang/p/12154970.html