實現腳本之前,需切換到指定目錄,再查看日志文件,前提是要求操作者需記住每個程序包或者控制台的路徑,否則還得打開環境清單一個個復制路徑。。。操作截圖以及logs.sh腳本如下:
1 #!/bin/bash 2 echo -e "\033[33m 請輸入需要查看的日志 \033[0m" #echo命令輸出字符串,使用-e參數進行換行 3 echo -e "\033[33m 1.weblogic 2.申辦接口 3.網關接口 4.nginx的access日志 5.nginx的error日志\033[0m" 4 echo -e "\033[33m 6.窗口一體化接口 7.政務認證接口 \033[0m" 5 echo -e "\033[33m ------------------------------------------- \033[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 ~