Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.

  • Published on

  • View

  • Download

Embed Size (px)


  • Slide 1

Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes Slide 2 Batch Slide 3 CTSS Slide 4 Multiprogramming DMA & relocation Multics Slide 5 Objectives Categorize the different types of processes on a Linux system View processes using standard Linux utilities Illustrate the difference between common kill signals Describe how binary programs and shell scripts are executed Slide 6 Objectives Create and manipulate background processes Use standard Linux utilities to modify the priority of a process Schedule commands to execute in the future using the at daemon Schedule commands to execute repetitively using the cron daemon Slide 7 Linux Processes Program Structured set of command stored in an executable file on a filesystem It may be executed to create a process Process A program that is running in memory and on the CPU Slide 8 Linux Processes User process Process begun by a user that runs on a terminal Daemon process System process that is not associated with a terminal Process ID (PID) Unique identifier assigned to every process as it begins Slide 9 Linux Processes Child processes Refers to a process that was started by another process (parent process) Parent processes Process that has started other processes (child processes) Parent Process ID (PPID) The PID of the parent process that created the current process Slide 10 Linux Processes Figure 11-1: Parent and child processes Slide 11 Linux Processes Figure 11-2: Process genealogy Slide 12 Viewing Processes There are several Linux utilities that can view processes ps command The most versatile and common Linux utility that can view processes Without arguments, the ps command simply displays a list of processes that are running in the current shell Slide 13 Viewing Processes Process state Current state of the process on the processor Most processes are in the sleeping or running state Zombie process Process that has finished executing, but whose parent has not yet released its PID Also know as defunct processes Slide 14 Viewing Processes Process priority (PRI) Number assigned to a process, used to determine how many time slices on the processor it will receive Nice value (NI) Value that indirectly represents the priority of a process The higher the value, the lower the priority Slide 15 Viewing Processes Table 11-1: Common options to the ps command Slide 16 Viewing Processes top command Most common command used to display processes aside from ps Displays its interactive screen listing processes organized by processor time Processes that use the most processor time are listed at the top of the screen Slide 17 Viewing Processes Rogue processes Process that has become faulty in some way and continues to consumes far more system resources than it should The top command can be used to change the priority of processes or kill them Slide 18 Killing Processes Kill signal Type of signal sent to a process by the kill command Different kill signals affect processes in different ways kill command Command that kills all instances of a process by command name Slide 19 Killing Processes Table 11-2: Common administrative kill signals Slide 20 Killing Processes Trapping The process of ignoring a kill signal killall command The command that kills all instances of a process by command name Slide 21 Process Execution The three main types of Linux commands that you may execute: Binary programs Shell scripts Shell functions Slide 22 Process Execution Forking The act of creating a new BASH shell child process from a parent Carried out by the fork function in the BASH shell Slide 23 Process Execution Figure 11-3: Process forking Slide 24 Running Processes in the Background Foreground processes Process for which the BASH shell that executed it must wait for its termination Background processes Process that does not require the BASH shell to wait for its termination Upon execution, the user receives the BASH shell prompt immediately Slide 25 Running Processes in the Background jobs command Command used to see the list of background processes running in the current shell foreground (fg) command Command used to run a background process in the foreground background (bg) command Command used to run a foreground process in the background Slide 26 Process Priorities Time slice The amount of time a process is given on a CPU in a multiprocessing operating system The more time slices a process has, the more time it has to execute on the CPU and the faster it will execute Time slices are usually measured in milliseconds Slide 27 Process Priorities Figure 11-4: The nice value scale Slide 28 Process Priorities Processes are started with a nice value of 0 by default On some Linux systems, background processes are given a nice value of 4 by default to lower the chance they will receive time slices nice command The command used to change the priority of a process as it is started Slide 29 Process Priorities renice command The command used to alter the nice value of a process currently running on the system As with the nice command, only the root user may change the nice value to a negative value using the renice command Slide 30 Scheduling Commands The at daemon (atd) The system daemon that executes tasks at a future time It is configured with the at command The cron daemon (crond) The system daemon that executes tasks repetitively in the future It is configured using cron tables Slide 31 Scheduling Commands with atd at command The command used to schedule commands and tasks to run at a preset time in the future Table 11-3: Common at commands Slide 32 Scheduling Commands with atd Table 11-3 (continued): Common at commands Slide 33 Scheduling Commands with atd /etc/at.allow A file listing all users who can use the at command /etc/at.deny A file listing all the users who cannot access the at command Slide 34 Scheduling Commands with crond Cron tables A file specifying tasks to be run by the cron daemon There are user cron tables and system cron tables They have six fields separated by space or tab characters Slide 35 Scheduling Commands with crond Figure 11-5: User cron table format Slide 36 Scheduling Commands with crond Figure 11-6: Sample user cron table entry Slide 37 Scheduling Commands with crond /var/spool/cron A directory that stores user cron tables /etc/cron.d A directory that contains additional system cron tables /etc/crontab The default system cron table Slide 38 User Cron Tables /etc/cron.allow A file listing all users who can use the cron command /etc/cron.deny A file listing all users who cannot access the cron command crontab command The command used to view and edit user cron tables Slide 39 The System Cron Table Linux systems are typically scheduled to run many commands during non-business hours These commands may perform system maintenance, back up data, or run CPU-intensive programs Most of these commands are scheduled by the cron daemon from entries in the system cron table /etc/crontable Slide 40 Chapter Summary Processes are programs that are executing on the system User processes are run in the same terminal as the user who has executed them, whereas daemon processes are system processes that do not run on a terminal Every process has a parent process associated with it and, optionally, several child processes Process information is stored in the /proc filesystem Slide 41 Chapter Summary Zombie and rogue processes that exist for long periods of time use up system resources and should be killed to improve system performance You may send kill signals using the kill, killall, and top commands The BASH shell forks a subshell to execute most commands Slide 42 Chapter Summary Processes may be run in the background by appending an & to the command name The priority of a process may be affected indirectly by altering its nice value Commands may be scheduled to run at a later time using the at and cron daemons


View more >