Loading...

Using watch to monitor processes

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

Using Linux you can monitor processes with watch. It executes a program periodically, showing the output in full screen.

This example monitors every 10 seconds if the logstash process is alive. We exclude the grep command itself.

watch -n 10 "ps auxww | grep \[l\]ogstash"

To monitor the database PostgreSQL, every process, that starts with postgres:

watch "ps auxww | grep ^postgres"

Example output

$ ps auxww | grep ^postgres
postgres   960  0.0  1.1  6104 1480 pts/1    SN   13:17   0:00 postgres -i
postgres   963  0.0  1.1  7084 1472 pts/1    SN   13:17   0:00 postgres: writer process
postgres   965  0.0  1.1  6152 1512 pts/1    SN   13:17   0:00 postgres: stats collector process
postgres   998  0.0  2.3  6532 2992 pts/1    SN   13:18   0:00 postgres: tgl runbug 127.0.0.1 idle
postgres  1003  0.0  2.4  6532 3128 pts/1    SN   13:19   0:00 postgres: tgl regression [local] SELECT waiting
postgres  1016  0.1  2.4  6532 3080 pts/1    SN   13:19   0:00 postgres: tgl regression [local] idle in transaction
Please remember the terms for blog comments.