Linux – watching output of “ps aux | grep blah” in tmux will not work

greplinuxpstmux

I am trying to run this –
watch "ps aux | grep myShittyProcess" in a tmux session. This process myShittyProcess was also started in a tmux session. The ps aux works without watch command. But as soon as I put it into watch, it fails to execute.
How to get this to work?

— edit –

Found that resizing tmux into full screen makes it work. Something to do with ps output wrapping and grep not able to find within wrapped context.

Best Answer

As mentioned in the question edit and xzfc's answer, the issue seems to be related to tmux's line wrapping. For something closer to a drop-in replacement of ps aux | grep [q]uote, if you don't need user information, try:

$ pgrep -af [q]uote
392 bash -c sleep 5 && echo quote
399 bash -c sleep 5 && echo second quote

$ watch pgrep -af [q]uote

The -a flag makes the output include the command line arguments, while -f lets you search the command line arguments as well as just the process name.