歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 如何記錄Linux終端下的操作日志

如何記錄Linux終端下的操作日志

日期:2017/2/28 16:39:13   编辑:Linux教程

  在Linux終端下,為方便檢查操作中可能出現的錯誤,以及避免屏幕滾屏的限制,我們可以把操作日志記錄下來。常用的工具有 screen,script,以及tee等。

  1. screen — screen manager with VT100/ANSI terminal emulatio

  > screen -L

  這裡是我們的操作

  > exit

  結束後會生成一個類似這樣的文件名: screenlog.0

  > more screenlog.0

  這樣可以查看你剛才進行的操作,發現可能存在的問題

  2. script — make typescript of terminal session

  > script

  我們的操作

  > exit

  生成一個這樣的文件:typescript

  > more typescript

  這裡查看我們進行的操作

  3. tee – read from standard input and write to standard output and files

  這個命令可以讀取終端輸入輸出到終端或者文件中,有時候可以用來記錄make等命令可能產生的輸出到終端的大量內容輸出到文件中去。這樣可以方便記 錄這些命令的日志。

  > make 2>&1 | tee make.log

Copyright © Linux教程網 All Rights Reserved