Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: nicksthegreat on April 06, 2004, 01:36:33 PM

Title: BASH SHELL SCRIPT
Post by: nicksthegreat on April 06, 2004, 01:36:33 PM
Hey guys,

           Can anyone write me a Bash Shell Script which kills all process of a specified user? It would be superb with some echo before after the main statement running. Hope you guys can help me out.

Cheers,
nicksthegreat
Title: BASH SHELL SCRIPT
Post by: sudipta_cht on April 08, 2004, 10:02:04 AM
I will not write the entire thing out for you, but will give you kind of pseudocode
On your first line after #!/bin/sh
write
VARIABLE=`ps -aux | grep $1`
 where $1 is the user's id you supply at the command line
Next, the process ids are available in the second column of the output, and so a simple
cut -f 2
will yeild the proper process ids.
All that you now have to do is to run kill -HUP
for all these process ids.
Howzzzat?