Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write a script for killing some process

Status
Not open for further replies.

horse123

Technical User
Oct 13, 2003
17
0
0
AU
Hwo to write a script to killing process with
"nobody" and "1"
nobody 98208 1 0 13:20:31 - 0:00 cgiopac
nobody 104896 1 0 13:17:26 - 0:00 cgiopac
nobody 113322 1 0 13:20:18 - 0:00 cgiopac
nobody 143702 1 0 13:13:56 - 0:00 cgiopac
nobody 144388 135644 0 13:21:06 - 0:00 cgiopac
nobody 153008 1 0 13:15:50 - 0:00 cgiopac
nobody 158218 1 0 13:15:23 - 0:00 cgiopac
 
awk is your friend:
Code:
kill -15 `awk '$1==&quot;nobody&quot; && $3==1{print $2}' <YourFile`
or
Code:
kill -15 `YourCmd | awk '$1==&quot;nobody&quot; && $3==1{print $2}'`

Hope This Help
PH.
 
If you're using Solaris, use [tt]pkill[/tt].

Something like...
Code:
    pkill -KILL -U nobody -P 1
Hope this helps.

 


Hi,

Looking at the process' list, it seems the process
related to &quot;cgiopac&quot; is misbehaving. Find out who is
the parent of this process, and that process seems to be
misbehaving. All the processes in your list, whose parent
process id is 1 has already been inherited by init (their
parent exited abruptly, perhaps). I think it might not be
possible to kill such processes once init inherits them
(PPID=1). Correct me if i am wrong.

Thanks,
sisiro
 
It is normal for some processes to have init as their parent, especially those that are intended to run as daemons, or those designed to continue after you log out of your terminal session (for example nohupped processes).

Annihilannic.
 
That is alright; my analysis is based on this particular process listing. Something doesnt seem to be alright to me. Hopefully Horse123 can come back to us, and let us know what exactly is happening with this process, and whether he could kill those processes using the script. Then only we can conclude something :)
 
Thank you all, guys.

Now I have a script as follows:

ps -ef | grep cgiopac > cgio.ps
kill -9 `awk '$1==&quot;nobody&quot; && $3==1{print $2}' <cgio.ps`

How can I make it run automatically on the Unix server (AIX)? thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top