Created
July 18, 2016 11:37
-
-
Save evdenis/87ad1f6c4c3dec0b562a103c624277c8 to your computer and use it in GitHub Desktop.
Disable/Enable AP cores of cpu (Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
regexp='[0-9]*' | |
# Disable all APs | |
for i in /sys/devices/system/cpu/cpu* | |
do | |
cpu=${i##*/} | |
cpu_num="${cpu#cpu}" | |
if expr match "$cpu_num" "\($regexp\)" > /dev/null | |
then | |
if [ $cpu_num -eq 0 ] | |
then | |
continue | |
fi | |
echo 0 > $i/online && echo $i disabled | |
fi | |
done | |
cat /sys/devices/system/cpu/online | |
cat /sys/devices/system/cpu/offline | |
# Reenable all APs | |
for i in /sys/devices/system/cpu/cpu* | |
do | |
cpu=${i##*/} | |
cpu_num="${cpu#cpu}" | |
if expr match "$cpu_num" "\($regexp\)" > /dev/null | |
then | |
if [ $cpu_num -eq 0 ] | |
then | |
continue | |
fi | |
echo 1 > $i/online && echo $i enabled | |
fi | |
done | |
cat /sys/devices/system/cpu/online | |
cat /sys/devices/system/cpu/offline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment