First commit
This commit is contained in:
commit
dbc413595a
3 changed files with 37 additions and 0 deletions
5
README.md
Normal file
5
README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Assassinate
|
||||||
|
|
||||||
|
A shell utility used to kill all processes of some user.
|
||||||
|
Warn you if you try to kill some special user (init or root).
|
||||||
|
|
32
assassinate
Executable file
32
assassinate
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
# kill all other processes
|
||||||
|
|
||||||
|
function logexit {
|
||||||
|
print -P -- "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
(($#<1)) && logexit "Usage: ${0:t} user"
|
||||||
|
|
||||||
|
victim="$1"
|
||||||
|
|
||||||
|
function stopquestion() {
|
||||||
|
print -n -- "$* (y/n): "
|
||||||
|
read answer
|
||||||
|
case $answer in
|
||||||
|
y|Y) print -- "OK you've been warned!";;
|
||||||
|
*) exit 0 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
case $victim in
|
||||||
|
$USER) stopquestion "Are you sure to kill you own processes?";;
|
||||||
|
init|root) stopquestion "Are you sure to kill all '$victim' processes?";;
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
processlist=( $(ps aux | awk '{print $1" "$2}' | egrep '(krystelle|bastien|anna|jc)' | awk '{print $2}') )
|
||||||
|
|
||||||
|
(($#processlist == 0)) && logexit "No process for user $victim"
|
||||||
|
|
||||||
|
sudo kill -9 $processlist
|
BIN
man/man1/assassinate.1.gz
Normal file
BIN
man/man1/assassinate.1.gz
Normal file
Binary file not shown.
Loading…
Reference in a new issue