From 14cd016bdf1b28ef07220c469c738b5a986dbacf Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 27 Feb 2011 11:01:30 +0100 Subject: [PATCH] New libcgroup aware n. --- bin/n | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bin/n 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 -- 1.8.3.1