Count the number of running processes
The shell command ps
could be used to list most process statistics.
We can use this command piped with wc
to get the number of running processes in Linux, remember to remove the header of output, --no-headers
added.
-L
will also display threads.
|
If you want to count the processes of a specific user, use the following command:
|
If you want to count the number of spawned process by httpd
, these two commands will be your choice:
|
pgrep
is a very useful command to lookup running processes based on name, process ID and other attributes of a process.
Get the maximum number of processes
You may be curious about the number limit of running processes in a system.
On Linux, you could check the maximum number of processes with the command:
|
Or with sysctl
command:
|
Usually, 4194303 is the maximum limit for x86_64 and 32767 for x86. If you want to change the maximum number, you could write to /etc/sysctl.conf
:
|
Process number limit per user
The root user doesn’t have a limit on the number of processes, ulimit -a
will show all kinds of limitation of resource for a user.
Normally, a non-root user has a limit on the number of processes. If you want to change the limit on the number of processes for a particular user, you need to add an entry in /etc/security/limits.conf
.
|
Join my Email List for more insights, It's Free!😋