From d271d5589ad3b602765923de10340ee3e6bbf8c7 Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Sun, 16 Apr 2023 12:47:33 +0200 Subject: [PATCH] Ajout du script makeprio --- bin/makeprio | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 bin/makeprio diff --git a/bin/makeprio b/bin/makeprio new file mode 100755 index 0000000..a2d8d69 --- /dev/null +++ b/bin/makeprio @@ -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[@]}" +