Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
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 '11 at 18:03
add comment

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

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

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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