Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

nproc

Print the number of CPUs (cores/threads) that the current process can use.

Niveau
Dagelijks Linux
Groep
Systeeminformatie
Root nodig
Nee
Pakket
coreutils

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

--all
All installed processors, not only the available ones.
--ignore=N
Leave out N processors.
--help
Show help.
--version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Number of CPUs

    nproc
    2

    Usable now.

  2. 2All installed CPUs

    nproc --all
    4

    More than nproc = some are limited (affinity, cgroup, offline).

  3. 3Parallel build

    make -j"$(nproc)"

    One job per core.

  4. 4Keep one core free

    make -j"$(nproc --ignore=1)"

    The system stays usable.

  5. 5Compare with the load

    uptime; nproc

    Load above nproc = processes wait.

  6. 6Parallel compression

    xz -T"$(nproc)" big.tar

    All cores.

  7. 7In a container with a CPU limit

    podman run --rm --cpuset-cpus=0 registry.access.redhat.com/ubi10/ubi nproc
    1

    Containers see the limit.

  8. 8Limit a command to 2 CPUs

    taskset -c 0,1 nproc
    2

    CPU affinity changes the result.

  9. 9More details

    lscpu | grep -E '^(CPU\(s\)|Thread|Core|Socket)'

    Sockets, cores and threads.

  10. 10Script sizing

    WORKERS=$(( $(nproc) * 2 )); echo $WORKERS

    A common rule for web workers.

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man nproc