查看日志的脚本

思路php

1, 编写脚本: 在某个文件夹中新建一个文件,如 logsql

cd /opt/wwwroot/test/shell
vim log

添加内容以下,保存退出shell

#!/bin/bash

date=`date -d "now" +%Y%m%d` #当天日期
tail -f /opt/log/IfchangeTOB.${date}.log #查看当天日志的命令

2, 添加可执行权限vim

sudo chmod +x log

3, 将脚本添加至环境变量,这样不管在哪一个文件目录下均可以直接执行log命令安全

sudo ln -s [log的绝对路径,这里是/opt/wwwroot/test/shell/log] /usr/local/bin/

4, 测试执行bash

c80k2@c80k2-Vostro-3667❯~$ log
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	Gearman_Client class already loaded. Second attempt ignored. 
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	Gearman Library: Successfully connected to the server named "192.168.1.199:4730" 
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	Gearman Library: Performed task with function op_toboption with parameter 
2017-11-06T11:12:05+08:00 rootLogger: Severity: Warning  --> GearmanClient::doNormal(): _client_run_tasks(GEARMAN_SERVER_ERROR) function_not_exist:function not exist -> libgearman/client.cc:1594: pid(17013) /opt/wwwroot/thirdsrc/framework/libraries/Gearman_Client.php 133 
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	load logic:Logic_account  
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	load model:account/Model_account_userinfo_source  
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	load dao:account/Dao_account_userinfo_source  
2017-11-06T11:12:05+08:00 rootLogger: 	DEBUG	sql:SELECT source FROM thirdparty_channel_db.account_userinfo_source WHERE `uid` =  '81' LIMIT 1 
2017-11-06T11:12:06+08:00 rootLogger: 	DEBUG	Final output sent to browser 
2017-11-06T11:12:06+08:00 rootLogger: 	DEBUG	Total execution time: 0.9324

执行顺利测试

 

思考ui

一切结构性的操做均可以经过自动化脚原本执行,一次添加,永久使用,安全高效,节省时间.spa

下一步将生成查看开发环境,测试环境和线上环境的日志脚本.日志

相关文章
相关标签/搜索