I have a server where there are 144 procs and is being used by multiple people with the same account id. Is there any way I can see how many processors are free (in the terminal) so that I can schedule my program to run with the appropriate number of procs? top does give me the list, but I cannot scroll down and see when (something like) > 31 procs are busy. The server is behind a firewall, so installing htop is also not an option. I saw this How can I see how many processor cores are working? but it didn't help much. The taskset command mentioned here is giving me a bad usage error. Any help?
Asked
Active
Viewed 581 times
0
mitra
- 23
- 4
1 Answers
1
One simple way is to see how many processes are currently running according to the linux scheduler using:
grep procs_running /proc/stat
You may want to also take into consideration that some processes are temporarily blocked (say on I/O or waiting), so it may be also worth taking these into consideration:
grep procs_blocked /proc/stat
Colin Ian King
- 18,370
- 3
- 59
- 70
-
Is there any way I can pipe the name of the processes/programs which are running on these 'procs_running' into the terminal/file? – mitra Jan 08 '20 at 10:20
-
Try: ps -eo stat,command | egrep "^D|^R" | cut -b6- – Colin Ian King Jan 08 '20 at 10:32
-
Thanks a lot! That helped. :) – mitra Jan 08 '20 at 11:38
-
and @Colin Ian King, if it is not a bother, can you explain that command a bit? – mitra Jan 08 '20 at 11:40
-
ps: -e selects all the processes, -o stat,command prints out the process running status and command being run. The egrep filters out the processes in the D (uninterruptible sleep) and R (running) states. The cut -b6- strips off the leading 6 chars (the process state) of the output leaving you with just the process names of processes in the D and R states. – Colin Ian King Jan 08 '20 at 12:05