关闭cpu

Linux双核cpu转为单核运行 echo 0 > /sys/devices/system/cpu/cpu1/online
若你机器是双核的cpu,上面命令使你的第二个内核停止运行。
这样/sys/devices/system/cpu/cpu1/下的所有关于第二个内核的文件消失。
单核运行,cpu很容易就飙到100的,只需移动一下窗口。不知道省电否。


echo 1 > /sys/devices/system/cpu/cpu1/online
恢复双核运行

cat /sys/devices/system/cpu/online 可以显示你的当前工作的cpu数。

echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
可以设置你的cpu为省电模式

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
可用的模式

[root@shine cpufreq]# ls
affected_cpus               related_cpus                   scaling_governor
cpuinfo_cur_freq            scaling_available_frequencies  scaling_max_freq
cpuinfo_max_freq            scaling_available_governors    scaling_min_freq
cpuinfo_min_freq            scaling_cur_freq               scaling_setspeed
cpuinfo_transition_latency  scaling_driver                 stats

网上看到的脚本不知道是否管用
#!/bin/bash
# author: fcicq
# requirement:
# acpi,cpufreq
# a Dual Core CPU (like Intel core 2)
chkavg() {
thisloadavg=`cat /proc/loadavg | awk -F . '{print $1}'`
if [ $thisloadavg -ge 2 ]; then
# >2
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 0 ]; then
echo 1 > /sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed
elif [ $thisloadavg -ge 1 ]; then
# 1-2
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 1 ]; then
echo 0 > /sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
else
# 0-1
if [ `cat /sys/devices/system/cpu/cpu1/online` -eq 1 ]; then
echo 0 > /sys/devices/system/cpu/cpu1/online
fi
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
fi
}
while true; do
chkavg
sleep 60
done 

From: http://hi.baidu.com/black/item/4078cda5879bc6d85af19140

你可能感兴趣的:(cpu)