Ping 主機, 順便印出時間訊息

經常要測試某主機何時掛掉, 或者是何時已經恢復, 使用ping 來測試是最簡單的方式. 但是卻缺乏時間資訊,
因此上網找到超好用的指令, 來達到我的需求.

ping www.google.com | while read pong; do echo "$(date): $pong"; done | tee log.txt

這樣子, 隔天再把 log.txt 打開來看, 就知道主機何時掛掉, 何時恢復了.

參考資料: How to command “Ping” display time and date of ping

This entry was posted in IT, network. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *