Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
nproc prints how many processing units are available — limited by CPU affinity and cgroup settings. Use it to compare with the load average, or to choose the number of parallel jobs.
Zo schrijf je het
nproc [OPTION]...Opties 4
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Number of CPUs
nproc 2Usable now.
2All installed CPUs
nproc --all 4More than nproc = some are limited (affinity, cgroup, offline).
3Parallel build
make -j"$(nproc)"One job per core.
4Keep one core free
make -j"$(nproc --ignore=1)"The system stays usable.
5Compare with the load
uptime; nprocLoad above nproc = processes wait.
6Parallel compression
xz -T"$(nproc)" big.tarAll cores.
7In a container with a CPU limit
podman run --rm --cpuset-cpus=0 registry.access.redhat.com/ubi10/ubi nproc 1Containers see the limit.
8Limit a command to 2 CPUs
taskset -c 0,1 nproc 2CPU affinity changes the result.
9More details
Sockets, cores and threads.
10Script sizing
WORKERS=$(( $(nproc) * 2 )); echo $WORKERSA common rule for web workers.
Niets past bij dit filter.
Exitcodes
0 :: Done. 1 :: Error.