X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fn;fp=bin%2Fn;h=c4c8a8eba4a6c26477d37ca5e6028ced10495e03;hp=0000000000000000000000000000000000000000;hb=14cd016bdf1b28ef07220c469c738b5a986dbacf;hpb=f1fd1da97405a124a824d3808d6bc59df1b16b9b diff --git a/bin/n b/bin/n new file mode 100755 index 0000000..c4c8a8e --- /dev/null +++ b/bin/n @@ -0,0 +1,25 @@ +#! /bin/sh +if which ionice &>/dev/null;then + IONICE="ionice -c3" +else + IONICE="" +fi +if [ "$1" = --n-class ];then + CGPARAM="$2" + shift 2 +else + CGPARAM="n" +fi +CGPARAM="-g cpu,memory,blkio:$CGPARAM" +if cgexec $CGPARAM true 2>/dev/null;then + CGEXEC="cgexec $CGPARAM" + CGCLASSIFY="cgclassify $CGPARAM" +else + CGEXEC="" + CGCLASSIFY="true" +fi +unset CGPARAM +if [ -z "$*" ];then echo >&2 "No PID" +elif [ "$1" = "-p" ];then renice >/dev/null +19 "$@";test -n "$IONICE" && $IONICE "$@";(shift;$CGCLASSIFY "$@") +else exec nice -n19 $IONICE $CGEXEC "$@" +fi