Free Logging in tmux


To get started with tmux, a terminal multiplexer that is insanely useful when you have no other access than ssh, check this out.

For the rest who already know how wonderful tmux is…

You can actually use log the output of a tmux pane to a file. Using the history-limit parameter, you can use it to log many, many lines.
Modify the default tmux start-up settings.

vim ~/.tmux.conf

In the file type add the following line:

set-option –g history-limit 1000000

This means that you set tmux to have a scrollback buffer of 1000000 lines. Be careful with this though, setting it to too high a value may result in a lot of memory being used when using multiple window panes.

As user , go into tmux

> tmux

Run your program in tmux.

> your_program

In tmux

Press Control-B  , followed by : , then type

capture-pane –S -1000000

Press Control-B  , followed by : , then type

save-buffer /home/pier/history.txt

Of course, for more “serious” use-cases, you could consider something like Poco’s logger, but then you would have to embed it in your program.

Loading tmux on Boot in Linux


tmux is a wonderful tool for displaying virtual consoles on the linux command prompt screen. It’s the next best thing to getting actual GUI windows controllable with a mouse.

Mainly, I use it for ssh purposes. Where I can ssh to a pc that I know has tmux already launched in the background and type.

tmux a

which attaches the session to the on-going tmux background session, allowing you to see everything that is going on in that process. This is especially useful for embedded systems where there are multiple processes launched in the background and you want to monitor them all.

So I have a tmux script here:



#allow re-launch
/usr/bin/tmux has-session -t $SESSION 2> /dev/null && /usr/bin/tmux kill-session -t $SESSION
/usr/bin/tmux -2 new-session -d -s $SESSION

echo "Launching tmux"

/usr/bin/tmux split-window -h
/usr/bin/tmux split-window -v
/usr/bin/tmux select-pane -t 0

/usr/bin/tmux send-keys -t $SESSION.0 "cd /path/to/binary1folder" C-m
/usr/bin/tmux send-keys -t $SESSION.0 "./binary1" C-m

/usr/bin/tmux send-keys -t $SESSION.1 "cd /path/to/binary2folder" C-m
/usr/bin/tmux send-keys -t $SESSION.1 "./binary2" C-m

/usr/bin/tmux send-keys -t $SESSION.2 "cd /path/to/binary3folder" C-m
/usr/bin/tmux send-keys -t $SESSION.2 "./binary3" C-m

This basically opens up , three panes and splits the window horizontally first, then splitting again one of the split windows vertically. It then launches a binary in each of the window panes. I won’ t go too much into the scripting here as there are plenty of resources for doing so, like this.

Configuring tmux to boot on startup on CentOS 7

Normally this should be pretty straightforward, but I ran into some hiccups.


sudo nano /etc/rc.local

And edit the rc.local file to include

su -c /path/toyourscript/ -l your_user_id

-l your_user_id means that you do the launch of the script as the user your_user_id.

Make sure your rc.local is executable.

sudo chmod +x /etc/rc.local

And by right it should launch when CentOS boots, launching in the background which in turn launches tmux. However, I found that one of the abrt startup scripts, was interfering with the launching of the tmux process/binaries. It would hang at the console terminal of the tmux screens. Doing the following resolved the problem for me.

cd /etc/profile.d/
chmod -r

Basically, make non-readable, allowing the profile.d startup process to skip over this particular script. It’s kind of a hack, but it worked. I reckon at most I don’t get the automatic bug reporting tool notifications at the console. Note that this script is run depending on what type of installation you chose when installing CentOS. I think that the minimal installl doesn’t run into this issue.

Hope this it useful to you, let me know!

ps. Here’s a tmux cheat sheet.