Linux in General > Linux Development & Programming

BASH SHELL SCRIPT

(1/1)

nicksthegreat:
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

sudipta_cht:
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?

Navigation

[0] Message Index

Go to full version