#!/bin/bash
path_0=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
path_1=/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
path_2=/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
path_3=/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
if [ -w $path_0 ] && [ -w $path_1 ] && [ -w $path_2 ] && [ -w $path_3 ]; then
case $1 in
1)
echo "[Performance] 高性能模式"
mode=Performance
;;
2)
echo "[ondemand] 自动调整"
mode=ondemand
;;
3)
echo "[powersave] 低功耗模式"
mode=powersave
;;
-r)
echo "[CPU 0]" `cat $path_0`
echo "[CPU 1]" `cat $path_1`
echo "[CPU 2]" `cat $path_2`
echo "[CPU 3]" `cat $path_3`
exit
;;
-h)
echo "输入参数:
[performance] 1
[ondemand ] 2
[powersave] 3
[读取模式 ] -r"
exit
;;
*)
echo "Erro: 输入参数错误"
exit
;;
esac
echo $mode > $path_0
echo $mode > $path_1
echo $mode > $path_2
echo $mode > $path_3
else
echo "Erro: 权限不足"
fi
[1] 保存成脚本文件 performance.sh
[2] 赋予执行权限,以root身份运行(或者你有scaling_governor节点的权限)
[3-1] ./performance.sh 1 #高性能模式运行
[3-2] ./performance.sh -h #显示帮助