The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
kill process help thms_sum Shell Programming and Scripting 5 02-03-2008 05:27 AM
Process KILL rkrgarlapati Shell Programming and Scripting 2 09-22-2006 02:07 AM
my process is going to sleep mode after 12 hours but i need my process in in firsy pr mukesh_rakesh1 UNIX for Advanced & Expert Users 0 09-04-2006 11:43 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 01:24 PM
How to kill a process and get process id jmdiaz UNIX for Dummies Questions & Answers 5 07-31-2001 12:35 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-27-2007
Registered User
 

Join Date: Mar 2007
Posts: 4
how to start a process and make it sleep for 5 mins and then kill that process

how to start a process and make it sleep for 5 mins and then kill that process
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-27-2007
Dhruva's Avatar
Registered User
 

Join Date: Mar 2006
Location: India
Posts: 241
write a script and give sleep function in that.call it with background process by running
Code:
scriptname &
Reply With Quote
  #3 (permalink)  
Old 03-27-2007
Registered User
 

Join Date: Mar 2007
Posts: 4
I need a script like this

while [ 0 -le 5 ] #which is infinite while loop
do
./my_function_which_prints_hi_every_5secs #written in C & stored
sleep 10
killall -9 ./my_function_which_prints_hi_every_5secs #shuld kill program
done

Last edited by shrao; 03-27-2007 at 05:36 AM.
Reply With Quote
  #4 (permalink)  
Old 03-27-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,472
Code:
scriptname &; sleep 300; kill $!
Reply With Quote
  #5 (permalink)  
Old 03-27-2007
Registered User
 

Join Date: Mar 2007
Posts: 4
I am getting error no process killed for the command kill$!

I tried this method,still I am getting no process killed. can you justhelp in this
I=1
while [ $I -le 2 ]
do
scriptname &
sleep 10
killall -9 scriptname
echo $I
I=`expr $I + 1`
done
Reply With Quote
  #6 (permalink)  
Old 03-27-2007
Registered User
 

Join Date: Feb 2006
Location: Southern England
Posts: 102
Code:
do_something &
sleep 300
kill $!
Reply With Quote
  #7 (permalink)  
Old 03-27-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,472
Quote:
Originally Posted by shrao
I tried this method,still I am getting no process killed. can you justhelp in this
I=1
while [ $I -le 2 ]
do
scriptname &
sleep 10
killall -9 scriptname
echo $I
I=`expr $I + 1`
done
you havent used kill $! to kill the last background process
use that !

instead of
Quote:
killall -9 scriptname
use
Code:
kill $!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0