Created
December 28, 2012 04:43
-
-
Save upsuper/4394569 to your computer and use it in GitHub Desktop.
Switch number of CPU cores in Linux
This file contains hidden or 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 | |
| cat /proc/cpuinfo | grep processor | wc -l |
This file contains hidden or 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 | |
| cpus_dir="/sys/devices/system/cpu" | |
| for cpu in $(ls "$cpus_dir" | grep 'cpu[0-9]\+') | |
| do | |
| cpu_online="$cpus_dir/$cpu/online" | |
| if [[ -e "$cpu_online" && $(cat $cpu_online) = 0 ]] | |
| then | |
| echo 1 > "$cpu_online" | |
| fi | |
| done |
This file contains hidden or 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 | |
| cpus_dir="/sys/devices/system/cpu" | |
| for cpu in $(ls "$cpus_dir" | grep 'cpu[0-9]\+') | |
| do | |
| cpu_online="$cpus_dir/$cpu/online" | |
| if [[ -e "$cpu_online" && $(cat $cpu_online) = 1 ]] | |
| then | |
| echo 0 > "$cpu_online" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment