- 论坛徽章:
- 0
|
大家好:
我先给大家看段日志内容:
[root@localhost boot]# tail -n 20 /var/log/messages
Sep 3 19:52:06 localhost last message repeated 4 times
Sep 3 19:55:39 localhost last message repeated 4 times
Sep 3 19:57:06 localhost squid: Could not determine fully qualified hostname. Please set 'visible_hostname'
Sep 3 19:57:50 localhost squid: Could not determine fully qualified hostname. Please set 'visible_hostname'
Sep 3 19:59:53 localhost squid[30131]: Squid Parent: child process 30133 started
Sep 3 19:59:53 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:53 localhost squid[30131]: Squid Parent: child process 30133 exited due to signal 6
Sep 3 19:59:56 localhost squid[30131]: Squid Parent: child process 30135 started
Sep 3 19:59:56 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:56 localhost squid[30131]: Squid Parent: child process 30135 exited due to signal 6
Sep 3 19:59:59 localhost squid[30131]: Squid Parent: child process 30137 started
Sep 3 19:59:59 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:59 localhost squid[30131]: Squid Parent: child process 30137 exited due to signal 6
Sep 3 20:00:02 localhost squid[30131]: Squid Parent: child process 30158 started
Sep 3 20:00:03 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 20:00:03 localhost squid[30131]: Squid Parent: child process 30158 exited due to signal 6
Sep 3 20:00:04 localhost squid[30160]: Squid Parent: child process 30162 started
Sep 3 20:00:06 localhost squid[30131]: Squid Parent: child process 30166 started
Sep 3 20:00:06 localhost squid[30131]: Squid Parent: child process 30166 exited with status 1
Sep 3 20:00:06 localhost squid[30131]: Exiting due to repeated, frequent failures
我想用SHELL实现的功能是:用SHELL提取固定时间内的的日志记录行,并进行输出,最好用AWK实现.例如:我想提取19:55:39至20:00:02这段时间的日志,那么脚本的输出就应该是:
Sep 3 19:55:39 localhost last message repeated 4 times
Sep 3 19:57:06 localhost squid: Could not determine fully qualified hostname. Please set 'visible_hostname'
Sep 3 19:57:50 localhost squid: Could not determine fully qualified hostname. Please set 'visible_hostname'
Sep 3 19:59:53 localhost squid[30131]: Squid Parent: child process 30133 started
Sep 3 19:59:53 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:53 localhost squid[30131]: Squid Parent: child process 30133 exited due to signal 6
Sep 3 19:59:56 localhost squid[30131]: Squid Parent: child process 30135 started
Sep 3 19:59:56 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:56 localhost squid[30131]: Squid Parent: child process 30135 exited due to signal 6
Sep 3 19:59:59 localhost squid[30131]: Squid Parent: child process 30137 started
Sep 3 19:59:59 localhost (squid): ipcache_init: DNS name lookup tests failed.
Sep 3 19:59:59 localhost squid[30131]: Squid Parent: child process 30137 exited due to signal 6
Sep 3 20:00:02 localhost squid[30131]: Squid Parent: child process 30158 started
望高手捧场!谢谢!!! |
|