Warning: preg_replace(): Compilation failed: escape sequence is invalid in character class at offset 4 in /home/customer/www/theunixtips.com/public_html/wp-content/plugins/resume-builder/includes/class.resume-builder-enqueues.php on line 59

How to find number of CPUs on unix system

Newer processors are multi-core and could have hyper-threading enabled. So there are time when user may need to know how many cores (virtual) processors are available and how many Physical (real) processors are installed. CPU information can be retrieved via /usr/sbin/psrinfo on SunOS while it is available in /proc/cpuinfo on Linux. /proc/cpuinfo on Linux contains information about each available core. Following command combinations can be used to retrieve the number of CPUs.

OS Physical Processors Cores available
SunOS /usr/sbin/psrinfo -p /usr/sbin/psrinfo | wc -l
Linux grep “^physical id” /proc/cpuinfo | awk ‘{print $NF}’ | sort -u | wc -l grep processor /proc/cpuinfo | wc -l
IRIX hinv | grep -i processor | head -n1 | cut -d’ ‘ -f1

Update: Thanks Matias for tip on IRIX.

Comments are closed.