Install and configure GNU watch (gwatch) on AIX.

GNU’s Linux have an interesting command ‘GNU watch’ which its main function is not to watch your wife while you’re at work (Just kidding), its function is to  execute a program periodically, showing output fullscreen.

Interesting? Yes!

How many times we want to see output for any command at a regular intervals or repeatedly?

Watch is found on any Linux distros, but it’s not part of AIX OS. So, we can download it from

Like ‘multitail’ (, watch command for AIX has ncurses as packages dependencies.

Oooppppsssss wait, I see AIX’s OS has already a ‘watch’ command.. is the same command as ‘GNU watch’

No, ‘watch’ command from AIX OS is:

(lpar):[root] /tmp -> apropos watch
watch(1)        - Observes a programthat might be untrustworthy.

But in order to avoid conflict, ‘GNU watch’ will be renamed to ‘gwatch’instead of ‘watch’

Once you have download it:

(lpar):[root] /tmp -> ls *.rpm

Let’s install it (Remember ncurses dependencies)

(lpar):[root] /tmp -> rpm -Uvh watch-3.2.8-1.aix5.1.ppc.rpm
watch                       ##################################################

Verify gwatch is installed:

(lpar):[root] /tmp -> rpm -qa|grep watch

List files in package:

(lpar):[root] /tmp -> rpm -ql watch-3.2.8-1

To run the command on AIX, unlike on Linux, you should execute ‘gwatch’ instead ‘watch’:

(lpar):[root] /tmp -> gwatch
Usage: gwatch [-dhntv] [--differences[=cumulative]] [--help] [--interval=] [--no-title] [--version] <command></command>
So, let's play with gwatch 🙂
1- Let's see which ESTABLISH connections have our LPAR?

(lpar):[root] /tmp -> gwatch "netstat -an|grep ESTA"

Output will be similar to:

Every 2.0s: netstat -an|grep ESTA                                                                         Tue Nov 18 15:15:15 2014

tcp        0      0  172.1x.3x.7x.36054     172.1x.3x.7x.6192      ESTABLISHED
tcp        0      0  172.1x.3x.7x.36055     172.1x.3y.7x.6192      ESTABLISHED
tcp4       0      0  172.1x.32.10x.22       172.2x.1x7y.58793      ESTABLISHED
tcp4       0      0  172.1x.32.10x.22       172.2x.1x7y.58794      ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp4       0      0          ESTABLISHED
tcp        0      0  172.1x.3x.7x.1023      172.1x.3x.7x..6191     ESTABLISHED
tcp4       0      0  172.1x.32.101.22       172.2x.1x7y.49695      ESTABLISHED
tcp4       0      0  172.1x.32.101.22       172.2x.1x7y.49696      ESTABLISHED
tcp4       0      0        ESTABLISHED
tcp        0      0        ESTABLISHED

2- Suppose you are copying data to a FS, let’s monitor space on that FS. (‘-d’ option hightlights the latest changes)

(lpar):[root] /tmp -> gwatch -d -n 1 "df -k"

2.1 – See output

gwatch df

3- Suppose you have a startup script for your applications and it takes some minutes to start. We can use gwatch to see the progress of our script by executing ‘gwatch process ID’ of our startup script.

3.1- Let’s get the process id:

(lpar):[root] /tmp ->
/usr/local/bin -> ps -ef|grep     root  9830488  2752672   0   Nov 13      -  1:39 /usr/local/bin/

3.2 – Output will be similar to:

Every 2.0s: proctree 10027158                                                                             

9830488    /usr/local/bin/
   3866804    /bin/ksh /pconsole/lwi/bin/
      9896028    /bin/ksh /pconsole/lwi/bin/
         10027158    /usr/java5/bin/java -Xmx512m -Xms20m -Xscmx10m -Xshareclasses -Dfile.encoding=U

4- Who is logged in the system every 5seg:

(lpar):[root] /tmp/ -> gwatch -n 1 w

4.1 – Output sill be similar to:

  03:19PM   up 9 days,  21:19,  19 users,  load average: 2.82, 3.55, 3.83
pepe       pts/1        2014-03-17 12:42 (:0.0)
smith      pts/2        2014-03-18 19:30 (:0.0)
israel     pts/3        2013-11-25 18:52 (:0.0)
carlos     pts/4        2014-03-05 18:33 (:0.0)

Just thanks if the post was helpful 🙂


About igalvarez

More than 20 years experiences on IT industry. 20+ years in Unix experience : IBM-AIX, HMC/SDMC/IVM, SVC, Protectier, PureFlex Systems, VIOservers, IBM Bladecenters, IBM System Power, RedHat Linux, SuSE Linux, Debian/Ubuntu Linux. Solaris, SCO Unix, Tru64 Unix, Linux Virtualization: XEN, KVM, databases sb2, oracle, postgreSQL, Find more information here:
This entry was posted in AIX, gwatch, watch and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s