1

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
    Looks like this is a problem with parsing of windows.tmux. The new-window (same with new-session, split-window) command(s) of tmux cannot escape the quotes.
    – user5325
    Jun 29, 2017 at 16:15

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .