加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
autofreq.sh 977 Bytes
一键复制 编辑 原始数据 按行查看 历史
#!bin/bash
#this script just run onece
CORENUM1=4
CORENUM=$((${CORENUM1} - 1))
SETUSAGE=0.7
while :
do
NOWFREQ=`top -b -n1 | grep -v "Cpu(s)" | grep -v top | awk '{print $7}' | awk '{sum+=$1} END {print sum}'`
MAXUSAGE="$(awk 'BEGIN{print "'$CORENUM1'" * 100}')"
CURFREQ=`echo "$MAXUSAGE $NOWFREQ" | awk '{printf("%.2f",$2/$1)}'`
if [[ ${CURFREQ} ]] && [[ ${CURFREQ} > ${SETUSAGE} ]];then
for i in $(seq 0 $CORENUM); do
GETMODE="cat /sys/devices/system/cpu/cpu"$i"/cpufreq/scaling_governor"
NOWMODE=`$GETMODE`
if [ "$NOWMODE"x = powersavex ];then
/opt/bin/cpufreq-set -c $i -g performance
sleep 0.2
fi
#/opt/bin/cpufreq-set -c $i -g powersave
done
else
for i in $(seq 0 $CORENUM); do
GETMODE="cat /sys/devices/system/cpu/cpu"$i"/cpufreq/scaling_governor"
NOWMODE=`$GETMODE`
if [ "$NOWMODE"x = performancex ];then
/opt/bin/cpufreq-set -c $i -g powersave
sleep 0.2
fi
done
fi
# /opt/bin/cpufreq-set
sleep 5
done
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化