時(shí)間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)
在linux終端下,為方便檢查操作中可能出現(xiàn)的錯(cuò)誤,以及避免屏幕滾屏的限制,我們可以把操作日志記錄下來。常用的工具有 screen,script,以及tee等。
1. screen — screen manager with VT100/ANSI terminal emulatio
> screen -L
這里是我們的操作
> exit
結(jié)束后會(huì)生成一個(gè)類似這樣的文件名: screenlog.0
> more screenlog.0
這樣可以查看你剛才進(jìn)行的操作,發(fā)現(xiàn)可能存在的問題
2. script? — make typescript of terminal session
> script
我們的操作
> exit
生成一個(gè)這樣的文件:typescript
> more typescript
這里查看我們進(jìn)行的操作
3. tee –? read from standard input and write to standard output and files
這個(gè)命令可以讀取終端輸入輸出到終端或者文件中,有時(shí)候可以用來記錄make等命令可能產(chǎn)生的輸出到終端的大量?jī)?nèi)容輸出到文件中去。這樣可以方便記 錄這些命令的日志。
> make 2>&1 | tee make.log
當(dāng)然,我們也可以直接重定向到一個(gè)文件中
> make > make.log
PS: 2>&1是為了記錄錯(cuò)誤日志
if you want to filter the control symbols, try to use the "col" command like this:
$ cat screenlog.0 | col -b > screenlog
or
$ cat typescript | col -b > scriptlog
還有一個(gè)比較好用的命令tail -f
比如把輸出定向到text
./run.sh>text
tail -f? text 這個(gè)命令會(huì)follow輸出定向文件的內(nèi)容
關(guān)鍵詞標(biāo)簽:linux終端,linux操作日
相關(guān)閱讀
熱門文章
安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程
Tomcat9.0如何安裝_Tomcat9.0環(huán)境變量配置方法
多種操作系統(tǒng)NTP客戶端配置
Linux操作系統(tǒng)修改IP
人氣排行 Linux下獲取CPUID、硬盤序列號(hào)與MAC地址 dmidecode命令查看內(nèi)存型號(hào) linux tc實(shí)現(xiàn)ip流量限制 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 linux下解壓rar文件 lcx.exe、nc.exe、sc.exe入侵中的使用方法 Ubuntu linux 關(guān)機(jī)、重啟、注銷 命令 查看linux服務(wù)器硬盤IO讀寫負(fù)載