关闭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
可用的模式

# 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值