Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Hello everyone,
Sometimes I feel bad that the most I can contribute to this list is
"A Better Way To Do It" but...
Quoth James Williams:
> To the original poster: log into the machine as the user who ran the
> script that ran amuck and enter this:
>
> ps xa | cut -f1 -d" " | xargs kill -9
>
> Do *NOT* run this as root. I repeat - DO **NOT** RUN THIS AS ROOT.
> This will attempt to kill all processes on the system, but because of
> the permissions, will only the processes owned by the controlling user.
There are a number of concerns I have with the example command.
First of all it is inherently dangerous. "Getting used to" using
a certain command as a user invariably will get used when you are root,
and then look out. I have a counter-example in the same spirit as the
command above for removing a user's files:
1) Log in as the user
2) "rm -rf /"
I know this can be viewed as a real slam against James but I do not mean
it in that way.
Secondly, adding the "u" option to ps will report the userid,
which you can then egrep on and have a safer command. However, if you
are logged in as the user, you are going to kill your own shell and the
command pipe you are currently running. I will get to this below.
Third, sending a "-9" signal to a process is not the most polite
way possible to kill a process. What I have learned from others is that
the order in which to send signals is: -15, -2, -1, -9.
Fourth, the ps command is going to print a row of column headers,
and the "PID" column header is going to get sent to kill, which will gripe.
Fifth, kill is going to get the pids in increasing order. It is
preferable to kill child processes first, i.e. in decreasing order.
The command I would use is:
ps aux | awk 'NR>1 && $1=="victim" {print $2}' | sort -rn | xargs kill -15
Maybe I should try writing those useless columns in UNIX magazines...
David K. Drum
EMAIL:PROTECTED
--
It's hard to be bored when you're as stupid as a line. [1]
Reality has a tendency to be so uncomfortably real. [2]
When you proceed deliberately, mistakes don't cascade, they instruct. [3]
What you notice becomes your life. [4]
[1] Vernor Vinge [2] Neil Peart [3] Stewart Brand [4] Michael Chitwood