【業務】やっぱり!? シェルスクリプトは…偉大だお・゚・(つД`)・゚・
40代前半  東京都
2012/08/21 3:21
【業務】やっぱり!? シェルスクリプトは…偉大だお・゚・(つД`)・゚・
只今…明日の接続試験にしようする…!?
便利なログ取得方法を…!!
発見した…マコですお(≧∀≦)ノシ

ワクメの中にも!?
Serverの定期時間に…!!
ログ取得する人が居ると思いッ!!
この日記を書き残すお(`・ω・´)>シャキーン!!

【実行ファイル】
chmod→755等の、実行ファイル形式でッ!!

↓中身
#!/bin/sh←シェルお決まり呪文!!
while true ; do←繰り返し実行!!
date +"%H:%M:%S"←実行時間をディスプレイ表示
date +"%H:%M:%S" >> date_netstat-r.log←時刻を、指定ファイルに追記 ※この場合「date_netstat-r.log」ファイルにッ!!
netstat -rn←実行ファイルを記載ッ!!※複数可!!その場合、“sleep 5”の前に記載
netstat -rn >> date_netstat-r.log←「netstat -rn」コマンドを「date_netstat-r.log」ファイルに追記ッ!!
sleep 5←5秒休み
done←上に戻る(?)もしくは、「Ctl」+「C」でキャンセルする為の呪文!!
[root@xen-pbx download]#


【ログファイル】
[root@マコのServer]# cat date_netstat-r.log
03:02:40
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.65.64 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.33.32 0.0.0.0 255.255.255.240 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 192.168.33.33 0.0.0.0 UG 0 0 0 eth0
03:02:45
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.65.64 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.33.32 0.0.0.0 255.255.255.240 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 192.168.33.33 0.0.0.0 UG 0 0 0 eth0
03:02:50
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.65.64 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.33.32 0.0.0.0 255.255.255.240 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 192.168.33.33 0.0.0.0 UG 0 0 0 eth0
03:02:55
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.65.64 0.0.0.0 255.255.255.248 U 0 0 0 eth1
192.168.33.32 0.0.0.0 255.255.255.240 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 192.168.33.33 0.0.0.0 UG 0 0 0 eth0
[root@マコのServer]#

例では、5秒間隔だけど!?
“sleep 5”を3に変更すれば…!!
3秒間隔に( ̄ー ̄)bニヤリッ!!

これで明日は!?
多少…試験時間のゆとりが生まれるんでは…無いかお(`・ω・´)>シャキーン!!
ではでは…お休みなさいm(_ _)m
コメントする

…━…━…━…

無料会員登録はコチラ

…━…━…━…