有時候我們需要長時間蒐集log,在 linux 系統上可以用以下指令來在log內的每一行前面加上時間資訊,
方便我們做檢視比較。
指令:
run.sh | while read line ; do echo -e "$(date)\t $line" ; done > log.txt
Reference:
https://serverfault.com/questions/310098/how-to-add-a-timestamp-to-bash-script-log
https://serverfault.com/questions/80749/ping-replacement-that-shows-real-time
沒有留言:
張貼留言