On Linux, how to tell how many cores of the machine are active?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops
--
Chapters
00:00 On Linux, How To Tell How Many Cores Of The Machine Are Active?
00:26 Answer 1 Score 2
00:37 Answer 2 Score 6
01:05 Accepted Answer Score 28
01:29 Answer 4 Score 2
01:46 Thank you
--
Full question
https://superuser.com/questions/237413/o...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #core
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops
--
Chapters
00:00 On Linux, How To Tell How Many Cores Of The Machine Are Active?
00:26 Answer 1 Score 2
00:37 Answer 2 Score 6
01:05 Accepted Answer Score 28
01:29 Answer 4 Score 2
01:46 Thank you
--
Full question
https://superuser.com/questions/237413/o...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #core
#avk47
ACCEPTED ANSWER
Score 28
You can use top
to list the utilization of each core. Press 1 if necessary to split the CPU row into a separate row for each core.
You can also add a column that shows the last-used core for each process. Press f to bring up the field list, then j to activate the "P" column. Then press space to return to the live view.
ANSWER 2
Score 6
ps
has a field called psr
to tell you which processor a job is running on.
So you could use something like:
ps -e -o psr= | sort | uniq | wc -l
Note that merely running ps
like this will of course make at least one core active.
Probably better is to run this:
tmp=/tmp/ps.$$
ps -e -o psr= > /tmp/ps.$$
sort -u "$tmp" | wc -l
rm "$tmp"
that way the sort
and wc
do not increase the count.
ANSWER 3
Score 2
ANSWER 4
Score 2
htop
This command works good in both ubuntu and centos and shows graphically how many CPUs and how are they being used.
for centos:
yum install htop
for ubuntu:
apt-get install htop