#!/bin/bash
# chrt.sh
process='stress --io'
#process=$1
pid=$(ps x | grep "${process}" | grep -v grep | awk '{print $1}')
echo $pid
for element in ${pid[@]}
do
echo $element
chrt -f -p 1 $element
done
root@ubuntu:~/stress# ps axo pid,cmd,ni,%cpu,pri,rtprio,class | grep stress
32086 stress --io 2 0 0.0 19 - TS
32087 stress --io 2 0 91.8 19 - TS
32088 stress --io 2 0 91.8 19 - TS
57128 grep stress 0 0.0 19 - TS
root@ubuntu:~/stress# bash chrt.sh
32086 32087 32088
32086
32087
32088
root@ubuntu:~/stress# ps axo pid,cmd,ni,%cpu,pri,rtprio,class | grep stress
32086 stress --io 2 - 0.0 41 1 FF
32087 stress --io 2 - 91.8 41 1 FF
32088 stress --io 2 - 91.7 41 1 FF
57222 grep stress 0 0.0 19 - TS
root@ubuntu:~/stress#