|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Unix Script -- To Skip killing a specific process
Hi, By using Code:
ps -aux | awk '/mine/{split($15,a,"/");print $1,$2,a[length(a)]}'i get the below listed PID's with there corresponding processes. Code:
adm 1522 ABC_Process.tra adm 1939 GENE_Process.tra adm 2729 GENE_Archive.tra adm 3259 xyz_Process.tra I use Code:
ps -aux | awk '/mine/{split($15,a,"/");print $1,$2,a[length(a)]}' | while read a PID b; do kill -9 $PID; doneto kill the process gracefully. But from the listed processes i do not want "GENE" processes to be killed, and the rest should be. Is there a way to perform it in the unix script and print me the output of the same, in which GENE process should not be touched. Expecting output like : Code:
1522 ABC_Process.tra is killed gracefully 3259 XYZ_Process.tra is killed gracefully Any alternative ways are most welcome --- Murali.
Last edited by zaxxon; 07-16-2012 at 04:59 AM.. Reason: code tags, see PM |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
What do you mean GENE processes?
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Where do the words "is killed gracefully" in your expected output come from? There's nothing graceful about "kill -9". Since you have already concocted a somewhat overly-complicated command (which I'm sure someone will take the time to simplify), you could simply add a grep -v GENE before the while Code:
ps -aux | awk ... | grep -v GENE_ | while ... |
|
#4
|
|||
|
|||
|
kill -9 kills a process abruptly
to cleanly kill a process kill -15 is used. the difference between the two is, kill -9 murders the process [doesn't care if it has any unfinished job], whereas kill -15 requests the process to die hence, the process can finish it's unfinished jobs and die peacefulle [RIP ]you can google more about kill signals |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
We seem to have overlooked that this is posted in the Homework Forum. Please, in future, follow the guidelines for posting here. Thanks.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Finding the age of a unix process, killing old processes, killing zombie processes | sukerman | Shell Programming and Scripting | 0 | 04-14-2010 04:48 AM |
| Killing a process within 5 min it starts in Unix using perl | nishank.jain | Shell Programming and Scripting | 3 | 01-15-2010 04:14 AM |
| Killing specific process | benefactr | Shell Programming and Scripting | 6 | 10-25-2007 12:23 PM |
| killing a unix job after the job process gets completed | dtazv | Solaris | 7 | 09-28-2005 07:18 AM |
| killing unix job after the job process completes | dtazv | Shell Programming and Scripting | 1 | 07-22-2005 06:44 AM |
|
|