One minute
Number of cores
The following script displays the number of cores available in the system.
#!/bin/sh
echo "Bash version ${BASH_VERSION}..."
cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
echo "Number of cores in the system : ${cores}"
((coresusable=cores-1))
echo However, only "$coresusable" should be used
echo ""
if (eval "$@") >&/dev/null; then
perl -e 'printf "\033[30;102m[ OK ]\033[0m @ARGV\n"' "$@"
else
perl -e 'printf "\033[30;101m[FAIL]\033[0m @ARGV\n"' "$@"
fi
Example:
Bash version 3.2.57(1)-release...
Number of cores in the system : 4
However, only 3 should be used
[ OK ]
Read other posts