红联Linux门户
Linux帮助

linux日志文件过大,想要截取执行时间的日志信息 如何截取

发布时间:2017-01-11 09:47:46来源:linux网站作者:jiewenike
首先第一步查看你日志的时间格式:
09:28:06,651 ERROR [stderr] (http-/0.0.0.0:8080-1) org.springframework.jdbc.BadSqlGrammarException: 
09:28:06,656 ERROR [stderr] (http-/0.0.0.0:8080-1) ### Error updating database.  Cause: Java.sql.SQLSyntaxErrorException: ORA-01745: invalid host/bind variable name
09:28:06,656 ERROR [stderr] (http-/0.0.0.0:8080-1) 
09:28:06,656 ERROR [stderr] (http-/0.0.0.0:8080-1) ### The error may involve com.deppon.qms.module.lostgoodswarning.pojo.TLostReportFlowcodeEntity.insertForBatch-Inline
09:28:06,656 ERROR [stderr] (http-/0.0.0.0:8080-1) ### The error occurred while setting parameters
09:28:06,656 ERROR [stderr] (http-/0.0.0.0:8080-1) ### Cau
 
以上可以看出日志时间是以 09:28:06,656  这种形式的。
 
会正则表达式就可以这匹配 09:[0-9][0-9],我取的是九点钟的,所以简单点儿,命令如下:
sed -n '/09:[0-9][0-9]/,/09:[0-9][0-9]/p' server.log>new.log
 
本文永久更新地址:http://www.linuxdiyf.com/linux/27696.html