forked from ahurac/dotfiles
Ajout du script makeprio
This commit is contained in:
parent
97feea790c
commit
d271d5589a
1 changed files with 38 additions and 0 deletions
38
bin/makeprio
Executable file
38
bin/makeprio
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Variables
|
||||
sudo=sudo
|
||||
renice=renice
|
||||
pid="$(pidof "$1")"
|
||||
|
||||
# Error function
|
||||
error() {
|
||||
>&2 echo -e "\033[1;31mERROR:\033[0m $1"; shift
|
||||
exit "${1:-1}"
|
||||
}
|
||||
|
||||
# Test if process exists
|
||||
if [[ -z $pid ]]; then
|
||||
error "No such process." 1
|
||||
else
|
||||
shift
|
||||
fi
|
||||
|
||||
# Arguments
|
||||
prio="${1:--20}"; shift
|
||||
|
||||
# Command building
|
||||
renice=(
|
||||
"$sudo"
|
||||
"$renice"
|
||||
"$prio"
|
||||
"$pid"
|
||||
)
|
||||
|
||||
# Debug
|
||||
#echo "${renice[@]}"
|
||||
#exit 0
|
||||
|
||||
# Execution
|
||||
"${renice[@]}"
|
||||
|
Loading…
Reference in a new issue