chrt更改进程优先级和wak

 

#!/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#

 

posted on 2022-05-05 20:17  tycoon3  阅读(110)  评论(0)    收藏  举报

导航