Details: Some ill-behaved processes, either intentional or not, could easily bring down a production system if they are not managed properly. For example, a careless programmer might repeatedly create processes, and within seconds, the system would become unresponsive and even crash eventually.
For the purpose of this lab, you will be using a program to simulate
various scenarios to stress test a system. The program can be
downloaded from here.
Compile the program and name the executable proc
.
ps
and top
commands to
identify those zombies. Note that proc
will try to
disguise itself, so, do not look for the name. Instead, try to look
at the status of the processes.
ps
and top
commands to identify
the process. Write a Bash script that will be run by the crontab
every minute to catch and kill any runaway process (excluding the root
processes) that consumes CPU time for more than 2 minutes. Be sure to
run './proc -h' multiple times and show that your script works.
Hint: It may be a little tricky to get the Bash script to work correctly. So, you may leave this section to the last. If this is the case, be sure to undo the next section, Revisit Runaway Processes, before coming back here.
/etc/security/limits.conf
as root and add a new line to
setup a hard limit for the CPU time to 2 minutes for your user
account. In order for the limit to work, all affected users have to
logout and log back in after the changes have been made. Run './proc
-h' again and run top
to show the runaway process is
killed when it goes beyond the limit.
proc
program and
try again.
Now, edit /etc/security/limits.conf
as root and add a new
line to setup a hard limit for the maximum number of processes to 20
for your user account. Remember to log yourself out and login again.
Run the same command again and show what happens. Additionally, run
'./proc -n 20' and see what happens. Explain why there are fewer
processes (should be 18 in this case) allowed to be created by
proc
.
proc
will clean up all the files it created. However, if it does not for
some reasons, you may remove them manually by running 'rm file_*.tmp'.
Now, edit /etc/security/limits.conf as root and add a new line to
setup a hard limit for the maximum number of open files to 20 for your
user account. Remember to log yourself out and login again. Run the
same command again and show what happens. Additionally, run './proc
-f 20' and see what happens. Explain why there are fewer open files
(should be 17 in this case) allowed to be created by
proc
.