System monitoring from the command line
Command Line – watch and fswatch

© Lead Image © Shao-Chun Wang, 123RF.com
Two monitoring tools, watch and fswatch, let you gather system information from the command line.
Most users familiar with Linux have probably used cron
or at
to schedule the running of commands. Both can be useful in their place: cron
for repeated scheduling of events and at
for scheduling an event once. However, what both lack is the ability to gather system information and respond to it unless you write a specific script. Usually, it is much easier to use watch
[1] and fswatch
[2] to do both these things. While watch
and fswatch
can be used simply to gather information or to check for possible security incursions, both can be tweaked to act like a scheduler with little effort and minimal script-writing ability.
watch
The purpose of watch
is to follow how a command's output changes over time (Figure 1). This information can be used for troubleshooting, as well as for keeping a root or regular user informed about system changes as new packages are installed or updated. In limited circumstances, it could also be used as a simpler replacement for at
or cron
. Several other common uses are shown in Table 1. By default, watch
runs every two seconds until closed or interrupted. The basic command structure is:
watch OPTIONS COMMAND
[...]
Buy this article as PDF
(incl. VAT)