Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm new to ssh and tmux. I want to run a rake task on a remote server via ssh but I want to shutdown my computer and want the task continue running on the server. So I discovered tmux with seems to do that, but last night I got an "write error, broken pipe" after i reattached the tmux session. My internet home internet is very instable, so i may got a new IP, is that a problem? So, how can I prevent this?

share|improve this question

migrated from stackoverflow.com Oct 21 '12 at 15:10

This question came from our site for professional and enthusiast programmers.

    
You mean the re-attach succeeded? or it failed with "write error"? Did you start tmux on your local computer or on the server? –  Thor Oct 17 '12 at 8:43
    
I ran tmux on my maschine. I did: tmux; ssh server.foo; rake something; close terminal + shut down computer. –  ThommyH Oct 17 '12 at 11:56

1 Answer 1

As I understand you, you want to leave a program running on a server and the program should run within tmux. To make this work you have to run tmux on the server.

Step-wise

client$ ssh server
server$ tmux
server$ program

[detach from tmux]

server$ exit
client$

To reattach you can do:

client$ ssh server
server$ tmux attach

In one line

client$ ssh -t server tmux new program

[detach]

If you add -d switch to new the tmux session will not attach, but run in the background. Something like this:

client$ ssh -qt server tmux new -d "'program'"

Note that you need to double quote the command if it contains whitespace.

Reattach with:

ssh -t server tmux attach
share|improve this answer
    
thanks that was what i meant :D –  ThommyH Nov 11 '12 at 20:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.