Detect number of CPUs on a machine

Filed under: Command line tools, One-liners

UPDATE: Steven pointed out (very nicely) that there’s no need for cat in this picture, grep would do just fine on its own. So, thanks Steven!

Detect how many CPU cores are present on the running machine:

grep -c processor /proc/cpuinfo

This can be very useful when writing multi-threaded programs to properly match the number of threads with the number of CPU cores.

Read the rest of this entry »

Posted on November 6th, 2009 by Valeriu Paloş

2 Comments »

Copyright ©2012 Valeriu Paloş. All rights reserved. Design based on a template from Hive Designs ported by Theme Lab.