Can I run watch with a subcommand?

Viewed 142

I'm trying to work out what our build process is doing, and I'm finding it really useful to run this:

watch pstree -a $(pgrep -f 'make -k -s')

in a terminal.

unfortunately pgrep -f 'make -k -s' gets evaluated once and for all, so it needs restarting every time a new build is run.

Is it possible to say to watch, 'run this whole thing every 2secs'

1 Answers

this works for me by putting

pstree -a $(pgrep -f 'make -k -s')

into a file as a little script i.e. testscript.sh

and then running

 watch sh testscript.sh
Related