Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically, I have a computer that I have to ssh into and pull up about 8 terminals to monitor various threads and log files. I would like to have a script from my build machine that can do this all for me. For example, if I want to watch the message queues, I'd like to run something like this:

gnome-terminal --window-with-profile=NOCLOSEPROFILE -e "ssh root@IP 'watch ipcs'" 

But the ssh command doesn't seem to execute properly. I've tried a dozen iterations of this, with no luck. Here is a screen shot, if that helps.

enter image description here

So basically, I want to have this be something I can put into a script, or even be something commandible, so given an ip address and a command to execute, I'd like a new terminal window to open an ssh connection to that ip and execute the command.

Thanks in advance

**EDIT I seem to be able to do this and execute most commands with the above command, but the watch command does not work over ssh so perhaps the sytax isn't the problem. Is there a reason watch might not work here, where

gnome-terminal --window-with-profile=NOCLOSEPROFILE -e 'ssh -X root@$IP "tail -f /home/log/alog.log"'

works fine?

share|improve this question
You almost certainly need to put your command in quotes. gnome-terminal --window-with-profile=NOCLOSEPROFILE -e "ssh root@IP 'watch ipcs'" You might also want to look at screen. – bodhi.zazen Jun 17 '13 at 22:00
I apologize, I mistyped. I am using quotes. Making edits now – zachd1_618 Jun 17 '13 at 22:02
Also consider doing log aggregation:… – Jorge Castro Jun 17 '13 at 22:39

Rather than opening up multiple windows and establishing multiple ssh sessions (to the same machine?), take a look at screen. You can ssh to a host, start screen and from there open multiple virtual consoles, one for each command you want to run.

What's really nice about screen, is that if you loose the ssh connection, you can create a new one and reattach to the running screen sessions. It's really cool. There is also tmux, which is a similar program (not sure how available it is on different Linuxes.


share|improve this answer

You are trying to run an interactive command that requires a tty, and by default, ssh does not allocate a tty when you specify a command to be run on the remote machine. Add the -t flag to force it to allocate a tty.

share|improve this answer

Your Answer


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.