Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I am working on an application that requires running many long running scripts, some of which I want to restart from time to time. Currently, I am trying to use gnome-terminal to solve this problem, so I have created a startup script that looks like:

#!/bin/bash -e
cd `hg root`

gnome-terminal \
  --tab \
    --working-directory=$PWD \
    --title run-server \
    -e ./bin/run-server.sh \
  --tab \
    --working-directory=$PWD \
    --title run-client \
    -e ./bin/run-client.sh \

# etc.

This creates the window and set of tabs that I want, so initially, everything looks great. The problem is that when I hit ctrl-C in the first tab to kill the server, it closes the tab. What I want to happen is for ./bin/run-server.sh to die and then I should be able to press up and then enter (because it should be the last thing in my history) to start it off again.

Is there a way to do this using gnome-terminal or equivalent on Ubuntu?

share|improve this question

migrated from stackoverflow.com Dec 2 '11 at 15:04

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

Instead of running the server directly, run an interactive shell with a custom init-script (one that runs the server) and a custom history-file as well. – n.m. Oct 10 '11 at 18:03

Have a look at screen. In particular it offers scriptable ways of creating new "tabs" and doing things to existing tabs.

share|improve this answer
Agreed, this is probably what you want to do... use a terminal multiplexer like screen, tmux to run each program in a seperate terminal (in the same window) which you can easily switch between, ctrl-c -> up -> enter whenever you want. – gabe. Dec 31 '11 at 19:56

Do you know about crontab and their ability to run programs unattached to any terminal? Output can be captured to log files and then viewed, greped and other manipulations as needed. See my answer in working with crontabs

I hope this helps.

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.