Test Development Linux Interview three: the operation of the background process

Source: Internet
Author: User

Hi, hello, I am Tom, after the last time to share this brings us new knowledge.

Processes are a very important concept in a Linux system. Linux is a multitasking operating system that often runs multiple processes at the same time. We don't care how these processes are distributed or how the kernel manages the allocation of time slices, and the concern is how to control these processes so that they can serve the user well.

The Linux operating system consists of three different types of processes, each of which has its own characteristics and attributes. An interactive process is a process that is initiated by a shell. The interactive process can be run either in the foreground or in the background. The batch process and terminal are not linked, and are a sequence of processes. A process that is started when the Linux system starts and runs in the background when the process is monitored (also called the System daemon). For example, HTTPD is the well-known Apache server monitoring process.

The KILL command works by sending a system operation signal to the kernel of the Linux system and the process identification number of a program, and then the system kernel can operate on the processes specified by the process identification number. For example, in the top command, we see that the system runs many processes, and sometimes it needs to use kill to abort some processes to improve system resources. When explaining the installation and landing commands, it was mentioned that the function of multiple virtual consoles is to switch to another virtual Console to shut down the program when a program error causes the system to deadlock. The command that is used at this point is kill, because Kill is a direct call to most shell internal commands.

As a test we do not need to know that Linux is too low-level knowledge, but we sometimes need to see if the service process is normal, we need to work on the process to assist the exception test, so the following commands for our daily work is very helpful, the interview will sometimes ask, if you can make the process concept clear + Daily command Proficiency, then this part will become your bonus points!

View basic information for a specified process

Ps-ef | grep Process Name keyword

View the status of all processes

Ps-aux

Pausing a process

Kill-s PID

will continue to perform the paused task

Kill-s PID

Force a process to kill

Kill-s 9 pid

Kill the process

Kill-s PID

Interrupt

Kill-s 2

Exit

Kill-s 3

The killall command kills all processes within the same process group. It allows you to specify the name of the process to terminate, not the PID

You can use the name of the process directly instead of the process identification number

Killall-hup inetd

‘‘‘

In particular, it is important to note that the safest way to kill a process is to simply use the KILL command, without modifiers, without flags.

‘‘‘

End the process in an elegant way

Kill-l PID

The-l option tells the kill command to end the process in a way that appears to the user who started the process logged off. When this option is used, the kill command also attempts to kill the left child process. But this command is not always successful--you may still need to manually kill the child process before killing the parent process.

If the above methods can not solve your problem, then please continue to watch the lore!!!

This powerful and dangerous command forces the process to terminate abruptly at run time, and the process cannot clean itself up after the end. A hazard is a system resource that is not normally released, and is generally not recommended unless other methods are invalid. When using this command, be sure to confirm with ps-ef that there are no zombie processes left. The zombie process can be eliminated only by terminating the parent process. If the zombie process is adopted by INIT, the problem is more serious. Killing the init process means shutting down the system.

If there is a zombie process in the system, and its parent process is init, and the zombie process consumes a lot of system resources, then you need to restart the machine at some point to clear the process table.

To sum up, normal if you need to kill a process directly kill +pid process name is enough, you must remember to kill the accompanying child process or the zombie process, the command must be cautious!!!

Test Development Linux Interview three: the operation of the background process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.