From 탱이의 잡동사니
Jump to navigation Jump to search


Linux 명령어 watch 정보 정리


watch 명령어는 어떤 명령을 주기적으로 실행하고자 할 때 사용할 수 있는 프로그램이다.


 watch [options] command

  -b, --beep             beep if command has a non-zero exit
  -c, --color            interpret ANSI color sequences
  -d, --differences[=<permanent>]
                         highlight changes between updates
  -e, --errexit          exit if command has a non-zero exit
  -g, --chgexit          exit when output from command changes
  -n, --interval <secs>  seconds to wait between updates
  -p, --precise          attempt run command in precise intervals
  -t, --no-title         turn off header
  -x, --exec             pass command to exec instead of "sh -c"

 -h, --help     display this help and exit
 -v, --version  output version information and exit


-d, --differences [permanent]
  Highlight the differences between successive updates.  
  Option will read optional argument that changes highlight to be permanent, allowing to see what has changed at least once since first iteration.

-n, --interval seconds
  Specify update interval.  
  The command will not allow quicker than 0.1 second interval, in which the smaller values are converted.

-p, --precise
  Make watch attempt to run command every interval seconds. 
  Try it with ntptime and notice how the fractional seconds stays (nearly) the same, as opposed to normal mode where they continuously increase.

-t, --no-title
  Turn off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.

-b, --beep
  Beep if command has a non-zero exit.

-e, --errexit
  Freeze updates on command error, and exit after a key press.

-g, --chgexit
  Exit when the output of command changes.

-c, --color
  Interpret ANSI color sequences.

-x, --exec
  command is given to sh -c which means that you may need to use extra quoting to get the desired effect.
  This with the --exec option, which passes the command to exec(2) instead.

-h, --help
  Display help text and exit.

-v, --version
  Display version information and exit.


$ watch -n1 date

Every 1.0s: date                               Tue Aug 11 09:55:39 2015

Tue Aug 11 09:55:39 CEST 2015