How do you capture the output of a closed tmux session or keep the session open after program exits?
up vote
0
down vote
favorite
if I do this:
tmux new-session -d -s test ls
is there a way to keep the session open after ls
exits?
I would like to get the output later with this
tmux capture-pane -pt test
the same way that I can if I have a session that stays open like this
tmux new-session -d -s test "tail -f testfile.txt"
Or is there another way to capture the output of a session that already existed?
tmux
add a comment |
up vote
0
down vote
favorite
if I do this:
tmux new-session -d -s test ls
is there a way to keep the session open after ls
exits?
I would like to get the output later with this
tmux capture-pane -pt test
the same way that I can if I have a session that stays open like this
tmux new-session -d -s test "tail -f testfile.txt"
Or is there another way to capture the output of a session that already existed?
tmux
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
if I do this:
tmux new-session -d -s test ls
is there a way to keep the session open after ls
exits?
I would like to get the output later with this
tmux capture-pane -pt test
the same way that I can if I have a session that stays open like this
tmux new-session -d -s test "tail -f testfile.txt"
Or is there another way to capture the output of a session that already existed?
tmux
if I do this:
tmux new-session -d -s test ls
is there a way to keep the session open after ls
exits?
I would like to get the output later with this
tmux capture-pane -pt test
the same way that I can if I have a session that stays open like this
tmux new-session -d -s test "tail -f testfile.txt"
Or is there another way to capture the output of a session that already existed?
tmux
tmux
asked Nov 19 at 21:02
Alex028502
1,165616
1,165616
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The easiest way would be to create the session without a specific command, and then call the command later. For instance:
tmux new-session -d -s test
tmux send-keys -t test "ls" Enter
tmux capture pane -t test -p
This is an odd use of tmux and it seems like nohup ls &>>~/mylog.out &
might better match your goal.
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: usingtimeout
if this is a timed command; usingbg
andfg
; actually connecting to the tmux session and manually typing things and seeing the logs; usingnohup
as described and killing withps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.
– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The easiest way would be to create the session without a specific command, and then call the command later. For instance:
tmux new-session -d -s test
tmux send-keys -t test "ls" Enter
tmux capture pane -t test -p
This is an odd use of tmux and it seems like nohup ls &>>~/mylog.out &
might better match your goal.
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: usingtimeout
if this is a timed command; usingbg
andfg
; actually connecting to the tmux session and manually typing things and seeing the logs; usingnohup
as described and killing withps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.
– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
add a comment |
up vote
1
down vote
accepted
The easiest way would be to create the session without a specific command, and then call the command later. For instance:
tmux new-session -d -s test
tmux send-keys -t test "ls" Enter
tmux capture pane -t test -p
This is an odd use of tmux and it seems like nohup ls &>>~/mylog.out &
might better match your goal.
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: usingtimeout
if this is a timed command; usingbg
andfg
; actually connecting to the tmux session and manually typing things and seeing the logs; usingnohup
as described and killing withps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.
– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The easiest way would be to create the session without a specific command, and then call the command later. For instance:
tmux new-session -d -s test
tmux send-keys -t test "ls" Enter
tmux capture pane -t test -p
This is an odd use of tmux and it seems like nohup ls &>>~/mylog.out &
might better match your goal.
The easiest way would be to create the session without a specific command, and then call the command later. For instance:
tmux new-session -d -s test
tmux send-keys -t test "ls" Enter
tmux capture pane -t test -p
This is an odd use of tmux and it seems like nohup ls &>>~/mylog.out &
might better match your goal.
answered Nov 20 at 0:11
jeremysprofile
1,5941516
1,5941516
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: usingtimeout
if this is a timed command; usingbg
andfg
; actually connecting to the tmux session and manually typing things and seeing the logs; usingnohup
as described and killing withps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.
– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
add a comment |
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: usingtimeout
if this is a timed command; usingbg
andfg
; actually connecting to the tmux session and manually typing things and seeing the logs; usingnohup
as described and killing withps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.
– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
because I am using it with ffmpeg, and needed to send a 'q' to make the program stop. I think you can send a ctrl+c now, but the original blog post I followed used tmux and send 'q', so easiest just to keep using tmux. Only problem was it didn't show the output when it failed, but your solution works great.
– Alex028502
Nov 20 at 8:17
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: using
timeout
if this is a timed command; using bg
and fg
; actually connecting to the tmux session and manually typing things and seeing the logs; using nohup
as described and killing with ps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.– jeremysprofile
Nov 20 at 16:35
You can always stop any command running from the terminal with ctrl-c. Some other possible options to consider: using
timeout
if this is a timed command; using bg
and fg
; actually connecting to the tmux session and manually typing things and seeing the logs; using nohup
as described and killing with ps
. That being said, if my answer worked, you should accept it (click green checkmark by it) so that others know this question is resolved without having to click into it and read the whole thing.– jeremysprofile
Nov 20 at 16:35
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
I think you are meant to wait a day or two before accepting an answer, especially when there are probably more possibilities. I already upvoted your answer.
– Alex028502
Nov 20 at 16:47
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
stackoverflow.com/help/someone-answers Waiting is not a requirement unless you are attempting to answer your own question, but you are right that you have no obligation to accept my answer if you feel it is not good enough.
– jeremysprofile
Nov 20 at 16:56
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
It's good enough. It totally fixed my problem, but I usually wait anyhow.
– Alex028502
Nov 20 at 17:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382574%2fhow-do-you-capture-the-output-of-a-closed-tmux-session-or-keep-the-session-open%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown