RHCSA 8 Exam Practice Question 10 (Process Management In Linux)

What Should I know About The RHCSA Exam

RHCSA 8 Exam Practice question 10

Question

An SAP application process from the development server is being transported to your server, your server is the middle man that runs the quality assurance test (QAS) before it is transported to the production environment.

Three processes with the highest CPU utilization on your server is causing your server to be very slow. Find and list out these processes, stop the process with the lowest CPU utilization, and terminate the two highest processes.

Make sure to restart the httpd service, and make the service persistent before resuming the stopped process that will later be transported to the production server.

Please take note: The process ID of the httpd service should not change.

The question is based On managing process in Linux, and managing serices in Linux In The RHCSA, 8 Course on this website. If you have gone through this course, solving this wouldn’t be a problem.

RHCSA, 8 Course

Managing Process In Linux

Managing Services In Linux

Ask your Questions

Solution

NB: Watch the video to see how the scripts that was used was generated. However, you can simply use the one we used during the course of study.

1. find the processes consuming high CPU utilization on the system, use the command

[root@DRDEV1 ~]# top
top - 17:14:45 up  8:44,  3 users,  load average: 2.89, 2.89, 3.02
Tasks: 328 total,   4 running, 324 sleeping,   0 stopped,   0 zombie
%Cpu(s):  72.8/27.2  100[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||]
MiB Mem : 76.1/1806.2   [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||                        ]
MiB Swap:  5.1/1536.0   [|||||                                                                                               ]

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  8594 root      20   0   12696   3152   2892 R  43.2   0.2  10:06.07 load2
  8610 root      20   0    7324    904    840 R  43.2   0.0  10:04.49 dd
  8591 root      20   0   12696   3096   2832 S  11.6   0.2   4:01.06 load
  9677 root      20   0   64104   5120   4104 R   0.3   0.3   0:00.10 top
     1 root      20   0  179236  10720   7168 S   0.0   0.6   0:06.09 systemd
     2 root      20   0       0      0      0 S   0.0   0.0   0:00.01 kthreadd
     3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
     4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp
  0:00.00 rcu_par_gp
     6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-kblockd

From the top command, you can see the top 3 processes that have the highest CPU utilization.

The “dd” process is consuming between 35% and 45%

The “load” process is consuming between 13% to 20%,

The “load2” process is consuming between 35% to 45%

The question further says we should terminate the two highest processes and stop the lowest process.

Quick one: What if the question says you should identify the highest process?

Since the top command fluctuates, and you can’t really identify the highest process consuming CPU between the “dd” process and “load2” process, use the command,

[root@DRDEV1 ~]#  ps -eo pid,cmd,%cpu,%mem --sort=-%cpu |head -n 5

   PID CMD                         %CPU %MEM
  8610 dd if=/dev/zero of=/dev/nul 41.1  0.0
  8594 /bin/bash ./load2           40.3  0.1
  8591 /bin/bash ./load            16.2  0.1
  2754 /usr/libexec/sssd/sssd_kcm   0.2  1.5

you can now see that the “dd” process consumes more CPU than the “load2″ process”

2. Stop the process with the lowest CPU utilization.

[root@DRDEV1 ~]# kill -SIGSTOP 8591

3. Verify the process is stopped.

[root@DRDEV1 ~]# ps aux| grep 8591

root       8591 15.9  0.1  12696  3096 pts/2    T    16:49   8:01 /bin/bash ./load
root      10646  0.0  0.0  12108  1056 pts/2    R+   17:39   0:00 grep --color=auto 8591

The T symbol signifies a stopped process.

4. Terminate the two highest processes

since the question didn’t mention the type of termination signal, we can use “sigkill” or “sigterm”. However, it is recommended we always terminate a process gracefully, hence we use “sigterm”

[root@DRDEV1 ~]# kill -SIGTERM 8610

-bash: kill: (8610) - No such process
[6]-  Terminated              dd if=/dev/zero of=/dev/null
[root@DRDEV1 ~]# kill -SIGTERM 8594

5. Verify the processes have been terminated.

[root@DRDEV1 ~]# ps aux| grep 8594

root      10756  0.0  0.0  12108   976 pts/2    R+   17:51   0:00 grep --color=auto 8594
[root@DRDEV1 ~]# ps aux| grep 8610

root      10758  0.0  0.0  12108  1056 pts/2    R+   17:51   0:00 grep --color=auto 8610

You can also use the top command to verify if you wish.

The question further states that we should restart the httpd service and make sure the PID of httpd service still remains the same.

During the course of the RHCSA 8 course on this chapter, I differentiated the difference between the restart and the reload command.

6. Verify the httpd PID

[root@DRDEV1 ~]# pidof httpd

14036 14035 14034 14033 13806

7. Reload the httpd service

[root@DRDEV1 ~]# systemctl reload httpd

8. Verify the PID again.

[root@DRDEV1 ~]# pidof httpd

13806

you can see that the PID still remains the same.

9. Verify the service is running

[root@DRDEV1 ~]# systemctl status httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-10-19 18:09:02 WAT; 4min 49s ago
    
RHCSA 8 Exam Practice Question 10

you can see that the service is disabled, the question says that the service should be persistent after a reboot. Hence, we need to enable the service.

Another command to verify if a service is enabled or disabled is

[root@DRDEV1 ~]# systemctl is-enabled httpd

disabled

10. Enable the service

[root@DRDEV1 ~]# systemctl enable httpd

Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

Lastly, the question says we should resume the stopped process.

11. Resume the stopped process, “load”

[root@DRDEV1 ~]# kill -SIGCONT 8591

12. Verify the process is resumed.

you can use the “top” command, or you use the command,

[root@DRDEV1 ~]# ps aux |grep 8591

root       8591 11.8  0.1  12696  3096 pts/2    R    16:49  10:51 /bin/bash ./load
root      15743  0.0  0.0  12108  1072 pts/2    R+   18:21   0:00 grep --color=auto 8591

Solution Summary

top

kill -SIGSTOP 8591

ps aux| grep 8591

kill -SIGTERM 8610

kill -SIGTERM 8594

ps aux| grep 8594

ps aux| grep 8610

pidof httpd

systemctl reload httpd

systemctl status httpd

systemctl is-enabled httpd

systemctl enable httpd

kill -SIGCONT 8591

ps aux |grep 8591

You can also watch the Video on RHCSA 8 Exam Practice Question 10 by clicking the link below.

Your feedback is welcomed. If you love others, you will share with others

Be the first to comment

Leave a Reply

Your email address will not be published.


*