私がコマンドを実行すると
$ nproc --all
4
説明 現在のプロセスで使用可能な処理装置の数を印刷します。これは、オンラインプロセッサの数より少なくてもよい。
current process
との概念を明示していますonline processors
。
psを使用すると、13個のプロセスが出力されます。
$ ps | sed '1d' | nl
1 363 ttys000 0:01.09 -bash
2 12779 ttys000 0:00.00 sed 1d
3 12780 ttys000 0:00.00 nl
4 12781 ttys000 0:00.00 sed s/me/me/g
5 397 ttys001 0:00.26 -bash
6 10088 ttys001 0:00.01 man bg
7 10089 ttys001 0:00.01 sh -c (cd '/usr/share/man' && (echo ".ll 10.2i"; echo ".nr LL 10.2i"; /bin/cat '/usr/share/man/man1/builtin.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | (/usr/bin/less -is || true))
8 10090 ttys001 0:00.01 sh -c (cd '/usr/share/man' && (echo ".ll 10.2i"; echo ".nr LL 10.2i"; /bin/cat '/usr/share/man/man1/builtin.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | (/usr/bin/less -is || true))
9 10095 ttys001 0:00.00 sh -c (cd '/usr/share/man' && (echo ".ll 10.2i"; echo ".nr LL 10.2i"; /bin/cat '/usr/share/man/man1/builtin.1') | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c | (/usr/bin/less -is || true))
10 10096 ttys001 0:00.01 /usr/bin/less -is
11 374 ttys002 0:00.21 -bash
12 438 ttys003 0:00.28 -bash
13 9965 ttys003 0:13.74 /Users/me/anaconda3/bin/python /Users/me/anaconda3/bin/ipython
オンラインプロセッサとはどういう意味ですか?nproc
psで置き換えられない特別な用途はありますか?
ベストアンサー1
nproc は使用可能な CPU 数をリストします。
psは現在、これらのCPUを使用しているアプリケーションをリストします。
CPU は特定のユーザーに限定されたり、冷却、電力、またはその他の目的のために動的にシャットダウンされ、ユーザーが CPU を使用できなくなる可能性があります。
仮想CPUやその他の複雑な問題(これはプロセスとプロセッサという用語がより正確になる)がありますが、これは短い答えです。