Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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
PATH=$PATH:$PWD/var/www/testGraduationProject1/public/Hume2Compiler/bin
humec -lotsaspace tails.hume
timeout 600 tails > hello.txt

See http://mywiki.wooledge.org/BashFAQ/068 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

 
discard

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.