Original author(s) | Tony Rems |
---|---|
Developer(s) | Francois Pinard, Mike Coleman, Albert Cahalan, Morty Abzug, Jarrod Lowe |
Initial release | 1991 |
Repository | gitlab |
Operating system | Unix-like |
Type | Command |
License | GPLv2.1+ |
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 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.
watch [options] command [command options]
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, such as 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.
-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 exitsBash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of rebirth.
In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program to process HTTP or HTTPS user requests.
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be command languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a wrapper.
The cron
command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs, also known as cron jobs, to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like downloading files from the Internet and downloading email at regular intervals.
xargs is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input. It converts input from standard input into arguments to a command.
top is a task manager or system monitor program, found in many Unix-like operating systems, that displays information about CPU and memory utilization.
In most Unix and Unix-like operating systems, the ps
program displays the currently-running processes. The related Unix utility top
provides a real-time view of the running processes.
In computing, netstat
is a command-line network utility that displays open network sockets, routing tables, and a number of network interface and network protocol statistics. It is available on Unix, Plan 9, Inferno, and Unix-like operating systems including macOS, Linux, Solaris and BSD. It is also available on IBM OS/2 and on Microsoft Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7, Windows 8 and Windows 10.
Code injection is a class of computer security exploits in which vulnerable computer programs or system processes fail to correctly handle external data, such as user input, leading to the program misinterpreting the data as a command that should be executed. An attacker using this method "injects" code into the program while it is running. Successful exploitation of a code injection vulnerability can result in data breaches, access to restricted or critical computer systems and the spread of malware.
The standard Unix command who
displays a list of users who are currently logged into the computer.
In Unix-like operating systems, find
is a command-line utility that locates files based on some user-specified criteria and either prints the pathname of each matched object or, if another action is requested, performs that action on each matched object.
In computing, more
is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more
is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.
tail is a program available on Unix, Unix-like systems, FreeDOS and MSX-DOS used to display the tail end of a text file or piped data.
In computing, tee
is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.
lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the retired Associate Director of the Purdue University Computing Center. It works in and supports several Unix flavors.
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or terminating of all processes in the job/process group; more advanced features can be performed by sending signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution.
pgrep
is a command-line utility initially written for use with the Solaris 7 operating system by Mike Shapiro. It has since been available in illumos and reimplemented for the Linux and BSDs. It searches for all the named processes that can be specified as extended regular expression patterns, and—by default—returns their process ID. Alternatives include pidof
and ps
.
Toybox is a free and open-source software implementation of over 200 Unix command line utilities such as ls, cp, and mv. The Toybox project was started in 2006, and became a 0BSD licensed BusyBox alternative. Toybox is used for most of Android's command-line tools in all currently supported Android versions, and is also used to build Android on Linux and macOS. All of the tools are tested on Linux, and many of them also work on BSD and macOS.
On Apple computers, pmset is a command line utility to manipulate power management settings under the Darwin and macOS operating systems. It can assign sleep settings, schedule sleep and wake times, and display power information.
A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.