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(0,-9) don't kill the process umen High Level Programming 9 06-19-2007 03:09 AM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
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 process from file naamas03 Post Here to Contact Site Administrators and Moderators 1 09-16-2005 05:03 AM
who -uH, kill the process at different pts/tb yls177 UNIX for Dummies Questions & Answers 3 12-11-2002 06:32 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-15-2005
Registered User
 

Join Date: Sep 2005
Posts: 78
Unhappy how to kill process from file

i have a script that read a file which contains process_id and time that he's
in and it lookes like this
0:30 54545
0:44 66788
0:90 23233
i need to read every line in the file and get the time and if the process is greater then 0:30 to kill the process id
the script looks like this
cat bbb | while read line
do
#kill -9 $i
done
i don't how to take of the hour , ask about it and kill the process
can you please help me and another question
did i do the loop ok did i need the pipe before the while
Reply With Quote
Forum Sponsor
  #2  
Old 09-15-2005
vertigo23's Avatar
Registered User
 

Join Date: Jul 2005
Location: SF, CA
Posts: 67
Your loops looks fine - you need to separate out the processID from the time; there's a couple different ways to do it. the easiest is with 'cut'.
Code:
proc=`echo $i | cut -f2 -d" "`
kill -9 $proc
Reply With Quote
  #3  
Old 09-15-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
Code:
#!/usr/bin/ksh

IFS='[ :<tab>]'

while read a b pid; do
   [[ $a$b -gt 30 ]] && kill $pid
done < bbb

Last edited by reborg; 09-15-2005 at 05:11 PM.
Reply With Quote
  #4  
Old 09-16-2005
Registered User
 

Join Date: Sep 2005
Posts: 78
Quote:
Originally Posted by vertigo23
Your loops looks fine - you need to separate out the processID from the time; there's a couple different ways to do it. the easiest is with 'cut'.
Code:
proc=`echo $i | cut -f2 -d" "`
kill -9 $proc
sorry i didn't understand
i need to ask about the time too if it's greater then 30 minutes
and the take of the process and kill it
the name of my file is bbb can you please help me
thanks a lot
Reply With Quote
  #5  
Old 09-16-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by naamas03
sorry i didn't understand
i need to ask about the time too if it's greater then 30 minutes
and the take of the process and kill it
the name of my file is bbb can you please help me
thanks a lot
Didnt you look at/try reborg's solution ?
Reply With Quote
  #6  
Old 09-17-2005
Registered User
 

Join Date: Sep 2005
Posts: 78
Quote:
Originally Posted by vino
Didnt you look at/try reborg's solution ?
how can i try if i can't understand which variables to put in ?
can someone please help me
Reply With Quote
  #7  
Old 09-17-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
Yes, if you explained a bit more clearly where you are having problems.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0