我想有/var/log/apache2/access.log的實時複製,所以我可以grep,做主機名解析等grepping數據阿帕奇access.log的
什麼是做的最好的方法這個?
我很好奇,看看有什麼樣的流量是由
我想有/var/log/apache2/access.log的實時複製,所以我可以grep,做主機名解析等grepping數據阿帕奇access.log的
什麼是做的最好的方法這個?
我很好奇,看看有什麼樣的流量是由
通過這樣做:
#Customize as appropriate:
tail -f /var/log/apache2/access.log | cut -f 0 -d ' ' &
tail -f /var/log/apache2/access.log | grep foo &
,你可以:
使用tail -f命令,但你必須保證以下命令緩衝,以讀取事件立即
tail -f /var/log/apache2/access.log | grep --line-buffered "something"
或
tail -f /var/log/apache2/access.log | sed -une "/something/p"
充分利用tail -f | grep
使用perl或python(perl是在日誌文件中進行grepping的好選擇)。
(該樣品是從人perlfaq5複製:
for (;;) {
for ($curpos = tell(GWFILE); <GWFILE>; $curpos = tell(GWFILE)) {
# search for some stuff and put it into files
}
# sleep for a while
seek(GWFILE, $curpos, 0); # seek to where we had been
}
你想去哪兒有這樣的實時副本,你要訪問它是如何做,如果你只是想在一個終端? ,使用'tail -f' –