Watch (Unix)
   HOME

TheInfoList



OR:

watch is a command-line tool, part of the
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
and packages, that runs the specified
command Command may refer to: Computing * Command (computing), a statement in a computer language * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on Apple Macintosh computer keyboards * ...
repeatedly and displays the results on
standard output In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
so the user 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.


Syntax

watch 'options''''command'' 'command options''


Example

watch " ps -e , grep php" This will generate a list of
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process, activities that produce a specific se ...
es 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 This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...


External links

*
procps

procps-ng
{{Unix commands Linux process- and task-management-related software