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?

  • 1
    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, 2011 at 18:03

2 Answers 2


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

  • 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, 2011 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .