Often I'll use tmux
to start a task that will be running for a while. I will periodically go back and check on it using tmux -a
and then disconnect if it still hasn't completed and check again later.
Is there any way to just see a brief snapshot of what's going on in the session without fully attaching? I'm looking for something like theoretically doing a tail
on the session to get the last bit of output ( but if I can avoid creating another file with a copy of the output all the better )
Maybe attaching and having it immediately detach would also work. I'm attempting to save keystrokes, perhaps such a command could be executed remotely,
i.e. ssh root@server tmux --tail
?
Best Answer
I think
capture-pane
might suit your needs:(see “target-pane” in the man page for the ways to specify a pane)
By default, that command will dump the current contents of the specified pane. You can specify a range of lines by using the
-S
and-E
options (start and end line numbers): the first line is 0, and negative numbers refer to lines from the pane’s “scroll back” history. So adding-S -10
gets you the most recent ten lines of history plus the current contents of the pane.The
-p
option was added in 1.8. If you are running an earlier version then you can do this instead:But mind those semicolons if you are issuing this command via
ssh
since the remote shell will add an additional level of shell interpretation (the semicolons need to be passed as arguments to the final tmux command, they must not be interpreted by either the local or the remote shell).