Skip to content

Instantly share code, notes, and snippets.

@jj1bdx
Created June 10, 2013 03:11
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jj1bdx/5746298 to your computer and use it in GitHub Desktop.
Save jj1bdx/5746298 to your computer and use it in GitHub Desktop.
Number of CPUs with getconf(1)
#!/bin/sh
# Originally from:
# https://github.com/blankpage/e5UNIXBuilder/blob/master/build-akili.sh
# Linux and similar...
CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
# FreeBSD and similar...
[ -z "$CPUS" ] && CPUS=`getconf NPROCESSORS_ONLN`
# Solaris and similar...
[ -z "$CPUS" ] && CPUS=`ksh93 -c 'getconf NPROCESSORS_ONLN'`
# Give up...
[ -z "$CPUS" ] && CPUS=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment