Identify processes that make heavy use of the CPU and memory

Identify processes that make heavy use of the CPU and memory, set the priority of processes renice and kill processes. Traditionally, in any unix ‘ps’ it is the command to identify the processes with their respective characteristics, qualities and states. This traditional command in GNUs systems supports 3 types of syntax for the parameters, namely: UNIX, BSD and GNU.  To simplify this post will use the UNIX syntax which allows grouping the various options and require.

Identify processes that make heavy use of the CPU and memory

Command syntax:

ps <Options> arguments

For example:

[root@TechTutorials ~]# ps -aux

It should be noted, ps is not equal to ps -a.
Process Snapshot (ps)

The ps command lists the processes depending on the parameters that we pass modifiers.

Let’s review the most relevant:

ps -e / -A List all processes

List -x processes that are associated with a terminal (TTY) -U Lists the processes associated with one or several users

-o it Used to determine which characteristics of the process will be listed

The most interesting -o parameters are:

  • % Cpu% CPU cpu utilization of the process in “##. #” Format.
  • % Mem% MEM ratio of the process’s resident set size to the physical memory on the machine, Expressed as a percentage
  • args COMMAND command With all its arguments as a string. Modifications to the arguments May be shown.
  • cgroup cgroup Control display groups to Which the process belongs.
  • or NI nice value. This ranges from 19 (nicest) to -20 (not nice to others)
  • pid PID to the process ID number Representing 
  • ppid PPID parent process ID

We can then combine these parameters in the following output:

[root@TechTutorials ~]# ps -e -o pid,% cpu,% mem, args

Which would give us the pid, the percentage of CPU used, the percentage of memory used and the arguments with which the program is run. Another interesting parameter is cgroup, because since we have systemd, all processes running under the control of a group (control group).
You can find these settings and many more doing ‘man ps’ in section STANDARD FORMAT Specifiers

The last tip is: to sort the output, use -sort, and specify on the basis that we want to sort the output parameter.

For example we ordain by percentage of CPU processing:

[root@TechTutorials ~]# ps -e -o pid,% cpu, cpu command --sort%

Table of Process (top)
Another classic command of UniXS, we will list the table real-time process and resource consumption. Also, default orders top processes by CPU consumption, which enables us to find which programs are consuming more resources.
R can be changed by pressing the priority number of a process and k can send a signal to kill the process.
You can find a good post on top here

Nice & renice

The UniXS systems allow processing set priorities for the CPU ‘focus’ mainly on certain tasks and relegates others.
Nice to execute a command with a given priority:

[root@TechTutorials ~]# nice -n 5 command --argument

If the process were already running, we can reassign the priority with renice referencing its pid:

[root@TechTutorials ~]# renice -n April 2345

Kill and derivatives

Finally, to eliminate a process, we have the kill command.

Unix establishes different signals that can send to a process, the most common are SIGHUP (1) (die and run again), SIGTERM (15) (notifies the process that has to end its execution, but gives you time to close the file descriptors and kill their children) and SIGKILL (9) (terminates the process immediately) l.

Thus, we can send these signals using the PID and the number of signal:

[root@TechTutorials ~]# kill -s September 2345

Killall and pkill allow us to do the same, but looking for the process name:

[root@TechTutorials ~]# killall -s 9 xchat

Another interesting post on the subject here


These topics are essential for any administrator linux / unix, so we just did a brief review, there is no difference in Red Hat 7 what we know at this point.

Related Articles

htop command in Linux

Linux File System Usage Monitoring Script

Thanks for your wonderful Support and Encouragement


My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published.