Re: command for finding out number of processors on a linux machine

Chris Green (greenc@fnal.gov)
Wed, 17 Nov 1999 09:29:13 -0600 (EST)

Hi,

Maximum efficiency, and deals with >10 cpus:

#!/bin/bash
cpus=`grep -c -e '^cpu[0-9]\+' /proc/stat`
if [ $cpus -eq 0 ]; then
echo You are running just one cpu.
else
echo You are running $cpus CPUs
fi
exit 0

Cheers,
Chris.