linux tailf命令詳解
linux tailf命令詳解
linux tailf命令是跟tail -f命令幾乎等同的一個命令,那么它具體用途是怎樣的呢?下面由學(xué)習(xí)啦小編為大家整理了linux tailf命令的相關(guān)知識,希望對大家有幫助!
一、linux tailf命令用途說明
tailf命令幾乎等同于tail -f,嚴(yán)格說來應(yīng)該與tail --follow=name更相似些。當(dāng)文件改名之后它也能繼續(xù)跟蹤,特別適合于日志文件的跟蹤(follow the growth of a log file)。與tail -f不同的是,如果文件不增長,它不會去訪問磁盤文件(It is similar to tail -f but does not access the file when it is not growing. This has the side effect of not updating the access time for the file, so a filesystem flush does not occur periodically when no log activity is happening.)。
tailf特別適合那些便攜機上跟蹤日志文件,因為它能省電,因為減少了磁盤訪問嘛(tailf is extremely useful for monitoring log files on a laptop when logging is infrequent and the user desires that the hard disk spin down to conserve battery life.)。tailf命令不是個腳本,而是一個用C代碼編譯后的二進制執(zhí)行文件,某些Linux安裝之后沒有這個命令,本文提供了怎么編譯安裝tailf命令的方法。
二、linux tailf命令常用參數(shù)
格式:tailf logfile
動態(tài)跟蹤日志文件logfile,最初的時候打印文件的最后10行內(nèi)容。
三、linux tailf命令使用示例
示例一 使用tailf命令跟蹤日志
[root@web imx_server]# tailf log/WEB.LOG
"seq": 5710,
"clientId": 1291343201649254,
"presenceStatus": "1"
} }})
16:09:21.324 DEBUG http-80-79 hyjc.cometd.CometdServlet - { "cid": 1291343201649002, "op": "recv", "ncc0": 175}
16:09:21.444 DEBUG http-80-32 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:21.506 DEBUG http-80-79 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:23.239 DEBUG http-80-45 hyjc.cometd.CometdServlet - { "cid": 1291343201649184, "op": "recv", "ncc0": 55}
16:09:23.327 DEBUG http-80-45 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:24.288 DEBUG http-80-145 hyjc.cometd.CometdServlet - { "cid": 1291283017076175, "op": "recv", "ncc0": 82}
16:09:24.339 DEBUG http-80-81 hyjc.cometd.CometdServlet - { "cid": 1291283017076151, "op": "recv", "ncc0": 142}
16:09:24.360 DEBUG http-80-64 hyjc.cometd.CometdServlet - { "cid": 1291343201649090, "op": "recv", "ncc0": 40}
16:09:24.359 DEBUG http-80-143 hyjc.cometd.CometdServlet - { "cid": 1291283017076176, "op": "recv", "ncc0": 66}
16:09:24.878 DEBUG http-80-145 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:24.892 DEBUG http-80-143 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:24.896 DEBUG http-80-64 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:24.906 DEBUG http-80-81 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:25.095 DEBUG http-80-115 hyjc.filter.AccessCounterFilter - uri=/imx/cometd/service
16:09:25.095 DEBUG http-80-115 hyjc.cometd.CometdServlet - msgType IMX_ACTIVE_TEST msgBody {"clientId":1291343201649002,"presenceStatus":"1","seq":385}
16:09:25.095 INFO http-80-115 imx.client.ImxClient - Tx IMX_ACTIVE_TEST{seq=5711,client_id=1291343201649002,presence_status=1(presence_status_online),}
16:09:25.095 DEBUG http-80-115 hyjc.cometd.CometdServlet - { "cid": 1291343201649002, "op": "send", "sent": 0, "rc": 1, "msg": { "mt": "IMX_ACTIVE_TEST", "mb": {
"seq": 5711,
"clientId": 1291343201649002,
"presenceStatus": "1"
} }}
Ctrl+C
[root@web imx_server]#