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 and shell scripting languages 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 09:27 AM
Process KILL rkrgarlapati Shell Programming and Scripting 2 09-22-2006 06: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-05-2006 03:43 AM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 05:24 PM
How to kill a process and get process id jmdiaz UNIX for Dummies Questions & Answers 5 07-31-2001 04:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2007
shrao shrao is offline
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
  #2 (permalink)  
Old 03-27-2007
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
write a script and give sleep function in that.call it with background process by running

Code:
scriptname &

  #3 (permalink)  
Old 03-27-2007
shrao shrao is offline
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 09:36 AM..
  #4 (permalink)  
Old 03-27-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958

Code:
scriptname &; sleep 300; kill $!

  #5 (permalink)  
Old 03-27-2007
shrao shrao is offline
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
  #6 (permalink)  
Old 03-27-2007
bigearsbilly bigearsbilly is offline
Registered User
  
 

Join Date: Feb 2006
Location: Southern England
Posts: 104

Code:
do_something &
sleep 300
kill $!

  #7 (permalink)  
Old 03-27-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
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 $!

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0