Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-30-2008, 05:36 AM   #1
LQ Newbie
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
Execution of a script to be stopped after "x" minutes of time

I have 2 scripts and which are embedded in main script
#We are currently in
#Some commands
#After executing above commands, we need to execute

In the above scenario, I don't want to be executed completely, instead, after some "x" minutes, execution of should be stopped and script should be executed.

Please Note: I am not supposed to change contents of

Please let me know if this is possible.

Thanks a lot.


Last edited by YSE; 09-30-2008 at 05:38 AM. Reason: Correction.
Old 09-30-2008, 07:19 AM   #2
Senior Member
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
Hopefully this should help you out.

./ &
VAR=`ps x | grep | cut -d" " -f1| head -1`
kill -9 $VAR
So you get the idea..
Old 10-01-2008, 12:37 AM   #3
LQ Newbie
Registered: Sep 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Originally Posted by w3bd3vil View Post
Hopefully this should help you out.

So you get the idea..

Thank you w3bd3vil for the prompt response.

I tried executing the commands and test my script. But is getting executed only after is completely executed.
Old 10-01-2008, 01:00 AM   #4
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 62
No need for all the scripting to get the PID of the backgrounded job. Use $! instead:

./ &
sleep 60
kill -TERM $PID
I don't understand your comment about getting executed after is completely executed. You indicated in your first post you wanted to being after x minutes. That's what the script above does ( starts 60 seconds after started).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
X Server broken. start w/ "INIT: ld "x" respawning too fast: disabled for 5 minutes&q tektone Linux - Hardware 5 07-25-2007 08:18 PM
execute a script every 5 minutes "cron" ALInux Linux - General 1 02-10-2006 03:36 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 03:32 PM
INIT: Id "x" respawning too fast: disabled for 5 minutes" Lego3 Linux - Software 0 06-16-2004 09:01 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration