* updated lskat (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / misc / archive / treenice.sh
blob0e573e9015704629d4d6c1df7d9738e3bb246ae0
1 #!/bin/sh
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 #
6 # T2 SDE: misc/archive/treenice.sh
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 main() {
19 renice $newpriority -p $1
20 ls /proc/$1/task | xargs renice $newpriority -p
21 for y in `cut -f1,4 -d' ' /proc/[0-9]*/stat | grep " $1\$" | cut -f1 -d' '`
22 do main $y "$2 " ; done
25 newpriority=$1
26 shift
28 if [ $# = 0 ] ; then
29 echo "Usage: $0 <new priority> <pid> [ <pid> [ ... ] ]"
30 exit 1
31 else
32 for x ; do
33 for y in $( ps -e -o pid,comm | tail -n +2 |
34 awk "\$1 == \"$x\" || \$2 == \"$x\" { print \$1; }" )
36 main $y ""
37 done
38 done
41 exit 0