Article Title: rational management of processes makes them the patron saint of Unix systems. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
A process in a Unix system refers to a program with specific functions. It can share operations on a data set with other programs. After a process is created by an application, it runs when resources are obtained. If no resources are available, stop temporarily until you obtain the required resources. After the process is completed, it will be cleared. The process is still different from the common program. Because the process is dynamic, and the program is a static concept. However, I think these descriptions are not intuitive. During my communication with you, the author compares the Unxi process as the patron saint of the system. He is responsible for communicating with the system CPU and ensuring the normal operation of the system.
Although the process is automatically generated by the application software. However, System Engineers still need to learn to adjust system processes when necessary. For example, some processes that have been running for a long time are put into the background for running. Here I will share my management experience on process management.
1. How to view the process ID?
After a process is created, the system assigns a unique identifier to it. The process indicates that the allowed range is a decimal number ranging from 0 to 65535. Generally, process identifiers are recycled. If the process ID reaches the upper bound, a smaller process number will be used again. The process number allocation principle in the system must be unique. Therefore, even processes initiated by the same application have different initiation times and process numbers. However, many operations on a process are performed on the process number. If you want to redirect the background process to the foreground or manually kill an unused process, you need to know the process ID. Therefore, in process management, The first thing System Engineers need to know is how to view the process Number of the system.
In Unix systems, can ps be used? Ef command to view all processes in the system. After you enter this command, the system displays detailed information about the processes in the current system. Specifically, it includes the following content. For example, UID indicates the owner of the process, PID indicates the identity of the Process, PPID indicates the identity of the parent process, TTY indicates the terminal of the running process, and COMMMAND indicates the system command for creating the process.
As a qualified Unix system engineer, you must be able to draw the following useful conclusions from this information.
First, the relationship between the child process and the parent process. Each process has only one parent process, but there can be multiple child processes. The process that creates other processes is called the parent process, and the created process is a child process. Why should we differentiate parent-child processes? For example, the system now has three processes with the process numbers 1001, 1002, and 1003, respectively. Process 1003 is created by process 1001. That is to say, process 1001 is created by process 1003. If, for some reason, the parent process 1001 is manually killed, its child process will also be killed or become an orphan process ". Therefore, when manually killing a process, the system engineer must first determine whether the process has created other sub-processes. System Engineers can kill the parent process only after determining that the manual shutdown of these child processes does not adversely affect the system. The obvious difference between a parent process and a child process lies in the process ID (PID) and the parent process ID (PPID ). If the child process is successfully created, the system fork process sends the PID of the child process to the parent process. Therefore, System Engineers should be able to determine who is the parent process based on the process identification number and parent process identification number; when manually disabling a parent process, pay attention to whether the created child process has adverse effects on the system.
Second, processes created by the system cannot be manually disabled. When a Unix system is started, the system core creates a sched process. Then the process generates three sub-processes, namely the init process, vhard process, and bdflush process. The processes of these four processes are marked as 0, 1, 2, and 3. Before the core scheduler allocates CPU time for them, shced schedules memory for other programs. Here, Unix System Engineers should note that they should not try to maintain these four processes, or forcibly shut down these four processes. Otherwise, the engineer will not be able to get any food.
[1] [2] Next page