R.A. Epigonos et al.

[linux] watch でコマンドを繰り返し実行、出力の違いを強調表示

watchコマンドを使うと、任意のコマンドを一定のインターバルで連続実行してくれる。さらに、このコマンドの出力の違いを強調表示してくれる。つまり、任意のコマンドの結果を定点観測できる。

例えば、マシンのチューニングのために、割り込みチェックをしたい場合、/proc/interruptsを定点観測する。そんな場合は、以下のようにする。-nでインターバルの秒数、-dで差分の強調表示。引数にコマンドを与える。終了するにはC-c。

# watch -n 5 -d cat /proc/interrupts

Every 5.0s: cat /proc/interrupts                        Sat Aug 21 06:03:31 2010

           CPU0
  0:         67   IO-APIC-edge      timer
  1:          2   IO-APIC-edge      i8042
  6:          3   IO-APIC-edge      floppy
  7:          0   IO-APIC-edge      parport0
  8:          2   IO-APIC-edge      rtc0
  9:          0   IO-APIC-fasteoi   acpi
 11:    3456590   IO-APIC-fasteoi   uhci_hcd:usb1, uhci_hcd:usb2, uhci_hcd:usb3
 14:     149720   IO-APIC-edge      ide0
 15:     134289   IO-APIC-edge      ide1
 16:   48729626   IO-APIC-fasteoi   eth2
 17:    2058933   IO-APIC-fasteoi   eth3
 18:     161595   IO-APIC-fasteoi   ide2, ide3, eth4
 19:    3465208   IO-APIC-fasteoi   eth0, eth1
NMI:          0   Non-maskable interrupts
LOC:    3587000   Local timer interrupts
RES:          0   Rescheduling interrupts
CAL:          0   function call interrupts
TLB:          0   TLB shootdowns
TRM:          0   Thermal event interrupts

リファレンス

  1. Manpage of WATCH
  2. manpage watch - Google 検索
  3. Shell command to monitor changes in a file - What's it called again?
  4. シェルコマンドは、ファイル - それは何も呼ばれる変化を監視するには?
  5. コマンド 違い 強調 linux シェル - Google 検索

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-07-09T06:11:11+09:00
  2. Modified: 2009-07-09T06:11:11+09:00
  3. Generated: 2023-08-27T23:09:12+09:00