nproc

nproc prints the number of processor cores available.

nproc [options]
$ nproc
8

By default it prints the number of cores available to the current process — which can be fewer than the machine has, if the process has been restricted to a subset. It is most often used to decide how many parallel jobs to run.

Options #

OptionEffect
--allPrint the number of cores the whole system has, ignoring any restriction on the current process.
--ignore=NSubtract N from the count — for leaving some cores free rather than using every one.

The environment variables OMP_NUM_THREADS and OMP_THREAD_LIMIT, if set, also bound the number nproc reports.

Exit status #

CodeMeaning
0The count was printed.
1An option value was invalid.

Edit this page