The accesskey generated by Apache. [01Aug2008: 14: 06: 30 + 0800] in the log file, which is converted to UTC time and then output as a new log file. How can we use Shell to implement access. an example recorded in log: 192.168.10.174
The accesskey generated by Apache. [01/Aug/2008: 14: 06: 30 + 0800] in the log file, convert it to the UTC time format, and then output it as a new log file, how to use Shell to implement access. example recorded in log: 192.168.10.174--[01/Aug/2008: 14: 06: 30 + 0800] GET/HTTP/1.
To add the part [01/Aug/2008: 14: 06: 30 + 0800] In the access. log file generated by Apache,
ConversionUTC
TimeAnd then output as a new
LogsFile, how to use Shell to implement
Here is an example recorded in access. log:
192.168.10.174--[01/Aug/2008: 14: 06: 30 + 0800] "GET/HTTP/1.1" 302 659 "-" "Mozilla/4.0 (compatible; MSIE 7.0; windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 31 + 0800] "GET/index. jsp HTTP/1.1 "200 16533"-"" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; slcc1 ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/ShowImageServlet? Id = 1 & lang = ja & bean = SolutionBean HTTP/1.1 "200 5083" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/ShowImageServlet? Id = 2 & lang = ja & bean = SolutionBean HTTP/1.1 "200 5148" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/images/favicon. ico HTTP/1.1 "200 5"-"" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; slcc1 ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/images/w3c_xhtml1.0.gif HTTP/1.1" 200 2333 "http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/images/zh/title.gif HTTP/1.1" 200 6606 "http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/include/MatrixOne.swf HTTP/1.1" 200 4073 "http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/Select. htc HTTP/1.1 "200 13800"-"" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; slcc1 ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/Select. htc HTTP/1.1 "200 13800"-"" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; slcc1 ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/check. js HTTP/1.1 "200 3619" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/initMenu. js HTTP/1.1 "200 17565" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/ja/souceXML. xml HTTP/1.1 "200 2604" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/script/styleSwitch. js HTTP/1.1 "200 1660" http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/style/gray % 20 window/bgImg.gif HTTP/1.1" 200 97 "http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
192.168.10.174--[01/Aug/2008: 14: 06: 32 + 0800] "GET/style/gray % 20 window/bottom_bg.jpg HTTP/1.1" 200 4657 "http: // 192.168.10.253/index. jsp "" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GoogleT5; Server Load balancer ;. net clr 2.0.50727 ;. net clr 3.0.04506 )"
Try:
$ Awk 'in in {FS = "[] []"; OFS = ""} {gsub (//, "-", $2); sub (/: /, "", $2); "date-ud \" "$2" \ "" | getline a; $2 = "[" a "]"; print} 'access. log
Or use gsed s/.../e
The whole earth is divided into twenty-four time zones, each time zone has its own local
Time. For international radio communication, a unified
TimeIs called Universal coordination Time (UTC, Universal Time Coordinated ).
For example, in my example, [01/Aug/2008: 14: 06: 30 + 0800] is a local
Time(Beijing)
Time)
UTC + time zone Difference = Local
Time
The Time Zone difference is positive in the east and negative in the West. Here, the UTC + 8 Zone Time Zone difference is recorded as + 0800,
UTC + (+ 0800) = Local (Beijing)
Time(1)
So, UTC = Local
Time(Beijing
Time)-0800 (2)
14:06:30-08:00:00 = 06:06:30 THIS IS UTC
TimeBut sometimes you will get
Time
This is also a problem...