无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Linux??注意!這個技巧讓你的腳本輸出永不丟失

2023-08-17 15:14 作者:微思網(wǎng)絡  | 我要投稿



對于??的Linux系統(tǒng)管理員來說,是否有過這樣的經(jīng)歷:在 crontab 計劃任務中運?了?個腳本,然后希望查看其輸出,卻因沒有合適的記錄?式?感到困擾?

有沒有想過讓腳本運?的所有輸出?動保存,以便于你在需要時隨時查看?

今天,我將向你展??個?法,讓你得?應?。

?先,我們需要?個腳本,我準備了?個名為 disktest.sh 的腳本,它的功能是創(chuàng)建?個?件并進?各種塊??的讀寫測試。腳本內容如下:

#!/bin/bash
echo?"creating?a?file?to?work?with"
dd?if=/dev/zero?of=/var/tmp/infile?count=1175000
for?bs?in?1k?2k?4k?8k?16k?32k?64k?128k?256k?512k?1M?2M 4M?8M
do
echo?"Testing?block?size?=?$bs"
dd?if=/var/tmp/infile?of=/var/tmp/outfile?bs=$bs
echo?""
done
rm?/var/tmp/infile?/var/tmp/outfile

讓這個腳本每分鐘運??次,并將所有的輸出保存到?志中

[root@localhost?~]#?crontab?-e
*?*?*?*?*?/root/disktest.sh?2>&1?|?logger?-t?disktest

意思是,每分鐘運??次/root/disktest.sh 腳本,并將所有的輸出重定向(2>&1)到 logger 命令。


logger 命令將這些輸出作為系統(tǒng)?志進?處理,并添加?個標簽 "disktest"


這樣,你的disktest.sh腳本的所有輸出就會被?動保存到/var/log/messages?件中。

當你運?disktest腳本后,你可以在messages?件中看到類似以下內容,它記錄了每?次的腳本輸出:

Aug?109:58:02localhost?disktest11048]:?Testingblocksize=1K
Aug?109:58:02localhost?disktest[11048]:587500+0recordsin
Aug?109:58:02?localhost?disktest[11048]:587500+0?records?out
Aug?109:58:02?localhost?disktest[11048]:601600000?bytes(602M574MiB)copied,?533701?s,
1.1GB/s
Aug?109:58:02?localhost?disktest[11048]:
Aug?109:58:02?localhost?disktest[11048]:Testingblocksize=2k
Aug?109:58:03localhost?disktest[11048]293750+0?recordsin
Aug?109:58:03localhost?disktest[11048]:293750+0?records?out
Aug?109:58:03localhost?disktest[11048]:601600000?bytes(602?M574?MiB)copied.379295?s,
1.6?GB/s
Aug?109:58:03?localhost?disktest[11048]:
Aug?109:58:03localhost?disktest[11048]:?Testingblocksize=4k
Aug?109:58:03localhost?disktest[11048]:?146875+0?recordsin
Aug?109:58:03localhost?disktest[11048]:?146875+0?records?out
Aug?109:58:03localhost?disktest[11048]:601600000?bytes602M574MBcopie?327263s,
1.8?GB/s
Aug?109:58:03localhost?disktest[11048]:
Aug?109:58:03localhost?disktest[11048]:Testingblocksize=8k
Aug?109:58:03localhost?disktest[11048]:?73437+1?recordsin
Aug?109:58:03localhost?disktest[11048]:?73437+1?records?out
Aug?109:58:03localhost?disktest[11048]:601600000?bytes(602MB574?MiBcopie?299182s,
2.0?GB/s
Aug109:58:03localhost?disktest[11048]:
Aug?109:58:03localhost?disktest[11048]?Testingblocksize=16k
Aug?109:58:04?localhost?disktest[11048]:36718+1?recordsin
Aug?109:58:04?localhost?disktest[11048]:36718+1?records?out
Aug?109:58:04localhost?disktest[11048]:601600000?bytes(602MB574MB)copied?282859s,
2.1?GB/s


這是?個簡單卻強?的技巧,相信你在未來的?作和學習中會發(fā)現(xiàn)其巨?的價值。




Linux??注意!這個技巧讓你的腳本輸出永不丟失的評論 (共 條)

分享到微博請遵守國家法律
宁乡县| 赤壁市| 孟村| 安图县| 新闻| 浠水县| 开原市| 定远县| 三门峡市| 东方市| 噶尔县| 白河县| 稻城县| 息烽县| 武威市| 江安县| 南漳县| 舟山市| 固阳县| 澎湖县| 黔西县| 奉新县| 监利县| 金华市| 河东区| 长泰县| 怀柔区| 渝中区| 松阳县| 彰化县| 定襄县| 施秉县| 黑龙江省| 凉山| 长垣县| 阿拉善左旗| 松桃| 新河县| 石门县| 和平区| 邯郸市|