Skip to content

Instantly share code, notes, and snippets.

@evdenis
Created July 18, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evdenis/87ad1f6c4c3dec0b562a103c624277c8 to your computer and use it in GitHub Desktop.
Save evdenis/87ad1f6c4c3dec0b562a103c624277c8 to your computer and use it in GitHub Desktop.
Disable/Enable AP cores of cpu (Linux)
#!/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