`watch`, `tail`, `grep` combination in `byobu`'s `windows.tmux`

I am (re)writing my windows.tmux for my frequently used byobu sessions. Below is my precise requirement:

I would like to have a tab (or window?) with a root prompt. (On start, it waits for the sudo passwd). I would like the second one to be split horizontally. In the upper portion I want to monitor my /var/log/syslog and in the lower one dmesg. So far I am able to achieve by doing the following:

new-session -AD -s 'root' sudo su - ;
new-window -n log watch -n 1 tail -n 15 /var/log/syslog
split-window watch dmesg | tail -15;

However the problem (which is completely irrelevant to this thread) that there are lots of entries in my syslog (almost 4/5 lines per second), which I would like to avoid while monitoring. So I would like to grep -v on these lines. The combination of watch, tail and grep can be achieved as per my need (thanks to steeldriver for his answer here.)

watch -n 1 'tail -n 15 /var/log/syslog | grep -v -E "pattern1|pattern2"'

Here begins the problem: If I include the following line in my window.tmux

new-window -n log watch -n 1 'tail -n 15 /var/log/syslog | grep -v -E "pattern1|pattern2"'

I get,

sh: 1: tail -n 15 /var/log/syslog | grep -v -E "pattern1|pattern2": not found

In fact the more general problem is if I encapsulate the command in quotes (whether single ' or double "), I get the same error.

Output of byobu --version is:

byobu version 5.116
tmux 2.3

I am using GNU bash, version 4.4.7(1)-release on 17.04.

Thanks in advance -- Mike

I have not experimented with screen. Is this achievable using screen?

1

1 Answer

In your bashrc create an alias

alias monitor_log='tail -n 15 /var/log/syslog | grep -v -E "pattern1|pattern1"'

Your windows.tmux can be:

new-session -AD -s 'root' sudo su - ;
new-window -n log;
split-window watch dmesg | tail -15;

This will give you a bash-prompt in the second window-top split and dmesg in the bottom. And then give your favourite watch command:

watch -n 1 'tail -n 15 /var/log/syslog | grep -v -E "pattern1|pattern2"'

Not sure you can create an alias for this!

Hope this helps.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like