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

I am a total noob in shell scripting. I am creating .sh file to make some multiple commands, but my problem is that the last command is an executable file that after excuting it stays open and the processes keep running in the terminal until i close the terminal or press Ctrl+ C or \. i want to kill this processes or quit the terminal which will also kill the process automatically while running the .sh file. this is the .sh file below. excuse my question if it was simple.

#!/usr/bin/env bash
cd ./var/www/testGraduationProject1/public/Hume2Compiler/bin/
export PATH=$PATH:`pwd`
humec -lotsaspace tails.hume;
./tails > hello.txt

//i have tried this two commands but they just stop the loading of process in terminal but without closing the terminal or the process itself.

killall tails
stty -a | grep inter
share|improve this question
You can send SIGQUIT with kill -3 <pid>. Not sure if that will do what you want though. – jpd May 29 '12 at 19:44
up vote 1 down vote accepted

Your question is vague, but I assume you're asking how to make the tails command run for N seconds then kill it?

If so, use the timeout command (installed by default in 12.04).

Here's your script using timeout (removed some redundant code while I was at it). It runs tails for 10 minutes (600 seconds) before killing it with the TERM signal.

#!/usr/bin/env bash
humec -lotsaspace tails.hume
timeout 600 tails > hello.txt

See for more information.

share|improve this answer
perfect this is better than what i needed. thank you – dori naji May 30 '12 at 0:03

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.