linux下即時查看tomcat作業記錄的方法_Linux

來源:互聯網
上載者:User

1、先切換到:cd usr/local/tomcat5/logs

2、tail -f catalina.out

3、這樣運行時就可以即時查看作業記錄了

Ctrl+c 是退出tail命令。

順便講一下Linux中tail命令

tail 命令從指定點開始將檔案寫到標準輸出.使用tail命令的-f選項可以方便的查閱正在改變的記錄檔,tail -f filename會把filename裡最尾部的內容顯示在螢幕上,並且不但重新整理,使你看到最新的檔案內容.

1.命令格式;

tail[必要參數][選擇參數][檔案]  

2.命令功能:

用於顯示指定檔案末尾內容,不指定檔案時,作為輸入資訊進行處理。常用查看記錄檔。

3.命令參數:

-f 迴圈讀取
-q 不顯示處理資訊
-v 顯示詳細的處理資訊
-c<數目> 顯示的位元組數
-n<行數> 顯示行數
--pid=PID 與-f合用,表示在進程ID,PID死掉之後結束.
-q, --quiet, --silent 從不輸出給出檔案名稱的首部
-s, --sleep-interval=S 與-f合用,表示在每次反覆的間隔休眠S秒

4.使用執行個體:

執行個體1:顯示檔案末尾內容

命令:

tail -n 5 log2014.log

輸出:

[root@localhost test]# tail -n 5 log2014.log 2014-092014-102014-112014-12==============================[root@localhost test]#

說明:

顯示檔案最後5行內容

執行個體2:迴圈查看檔案內容

命令:

tail -f test.log

輸出:

[root@localhost ~]# ping 192.168.120.204 > test.log &[1] 11891[root@localhost ~]# tail -f test.log PING 192.168.120.204 (192.168.120.204) 56(84) bytes of data.64 bytes from 192.168.120.204: icmp_seq=1 ttl=64 time=0.038 ms64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time=0.033 ms64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms64 bytes from 192.168.120.204: icmp_seq=6 ttl=64 time=0.026 ms64 bytes from 192.168.120.204: icmp_seq=7 ttl=64 time=0.030 ms64 bytes from 192.168.120.204: icmp_seq=8 ttl=64 time=0.029 ms64 bytes from 192.168.120.204: icmp_seq=9 ttl=64 time=0.044 ms64 bytes from 192.168.120.204: icmp_seq=10 ttl=64 time=0.033 ms64 bytes from 192.168.120.204: icmp_seq=11 ttl=64 time=0.027 ms[root@localhost ~]#

說明:

ping 192.168.120.204 > test.log & //在後台ping遠程主機。並輸出檔案到test.log;這種做法也使用於一個以上的檔案監視。用Ctrl+c來終止。

執行個體3:從第5行開始顯示檔案

命令:

tail -n +5 log2014.log

輸出:

[root@localhost test]# cat log2014.log 2014-012014-022014-032014-042014-052014-062014-072014-082014-092014-102014-112014-12==============================[root@localhost test]# tail -n +5 log2014.log2014-052014-062014-072014-082014-092014-102014-112014-12==============================

以上就是小編為大家帶來的linux下即時查看tomcat作業記錄的方法全部內容了,希望大家多多支援雲棲社區~

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.