我是新的perl,我有一個問題ie'如何使用perl腳本將個別日誌從linux服務器讀入另一個日誌文件',我需要捕捉不同的路徑和輸出在另一location.These日誌這些日誌文件,並存儲到文件的結果,個人日誌在Linux服務器生成..如何使用Perl腳本將個別日誌從linux服務器讀入另一個日誌文件
在此先感謝...
我是新的perl,我有一個問題ie'如何使用perl腳本將個別日誌從linux服務器讀入另一個日誌文件',我需要捕捉不同的路徑和輸出在另一location.These日誌這些日誌文件,並存儲到文件的結果,個人日誌在Linux服務器生成..如何使用Perl腳本將個別日誌從linux服務器讀入另一個日誌文件
在此先感謝...
您可以輕鬆地將它們全部集中在一起,如果這就是你想要的:
cat log1 log2 log3 > result
更新:
如果你想從不同的輸出文件的所有日誌最近的線,使用尾巴:
tail -50 /opt/psauto1/tester.log > /some/other/file
tail -50 /opt/psauto1/testdata.log > /some/other/file2
tail -50 /opt/view/test/itresult.log > /some/other/file3
tail -50 /opt/test/glr.log > /some/other/file4
tail -50 /opt/test/glr/glrdata.log > /some/other/file5
tail -50 /opt/test/glr/result.log > /some/other/file6
tail -50 /opttest/glr/output.log > /some/other/file7
,你甚至可以把它放進一個循環,並運行它每隔5秒:
while [ true ]
do
tail -50 /opt/psauto1/tester.log > /some/other/file
tail -50 /opt/psauto1/testdata.log > /some/other/file2
tail -50 /opt/view/test/itresult.log > /some/other/file3
tail -50 /opt/test/glr.log > /some/other/file4
tail -50 /opt/test/glr/glrdata.log > /some/other/file5
tail -50 /opt/test/glr/result.log > /some/other/file6
tail -50 /opttest/glr/output.log > /some/other/file7
sleep 5
done
我需要使用tail -f輸入路徑文件>輸出路徑文件從server.am捕獲最近的日誌,但一次沒有捕獲多個日誌。 – indu 2011-06-01 12:10:55
我有7個日誌I/P日誌,例如:1)/opt/psauto1/tester.log,2)/opt/psauto1/testdata.log,3)/opt/view/test/itresult.log,4)/ opt/test/glr.log,5)/opt/test/glr/glrdata.log,6)/opt/test/glr/result.log,7)/opttest/glr/output.log。所以,我想捕獲最近這些日誌到另一個位置的個人路徑... – indu 2011-06-01 12:28:01
@indu看到我的更新 – dogbane 2011-06-01 12:38:53
至於tail -f
,你可以做這樣的:
(
tail -f file1 &
tail -f file2 &
)>>total_file
()
將把命令組合在一起(fork
ing一個子shell),>>
將附加到一個文件,&
將強制命令到後臺。
至於Perl,select
在File::Tail手冊很多說明如何做到這一點。
你的意思是說你想將一組文件合併成一個文件?你爲什麼認爲你需要perl? – TLP 2011-06-01 11:34:54
不,我有單獨的路徑日誌文件在那裏運行Linux服務器,但我需要捕獲該日誌到單個文件的另一個位置。 – indu 2011-06-01 12:17:11
我不太明白你在做什麼。複製文件?只需檢查最近的幾行?我認爲你需要在這裏更清楚地瞭解你的需求。 – TLP 2011-06-01 22:34:02