Watch (Unix)

watch is a command-line tool, part of the Linux `procps` and `procps-ng` packages, that runs the specified command repeatedly and displays the results on standard output so you can watch it change over time. By default, the command is run every two seconds, although this is adjustable with the `-n secs` argument. Since the command is passed to `sh -c`, it may be necessary to encase it in quotes for it to run correctly.

## Contents

* 1 Syntax
* 2 Example
* 3 Arguments
* 4 See also
* 5 External links

## Syntax

watch [options] command [command options]

## Example

watch "ps -e | grep php"

This will generate a list of processes every two seconds, filter for all lines that contain the word "php", and display the results on the screen. The output might look something like this:

Every 2s: ps -e | grep php                             Tue Jan 30 14:56:33 2007

reconst  30028  0.0  0.0  7044 2596 ?        S    Jan23   0:00 vim -r core/html_api.php
cinonet  28009  0.0  0.2 20708 11064 ?       SN   Jan25   0:30 php5.cgi
donoiz   23810  0.0  0.2 22740 10996 ?       SN   Jan27   0:30 php.cgi 43/pdf

The watch command is useful for viewing changes over time, like repeatedly running the `ls -l` command to watch a file's size change, or running `ps` as in the above example to monitor certain processes continuously.

## Arguments

* `-d` – Highlights differences between iterations
* `-h` – Displays a help message, then exits
* `-n secs` – Specifies the interval between executions of the command in seconds
* `-t` – Tells watch not to display the header
* `-v` – Prints version information, then exits

## See also

* List of Unix commands

## External links

* `watch(1)`: execute a program periodically, showing output fullscreen – Linux User Commands Manual
* procps
* procps-ng

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Watch_(Unix)&oldid=798940"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template