Home  >  Article  >  Operation and Maintenance  >  What commands are used to view and schedule processes?

What commands are used to view and schedule processes?

藏色散人
藏色散人Original
2020-08-13 11:04:555162browse

The commands to view the process are ps and top, and the commands for process scheduling are at, crontab, batch and kill; a process is an address space in which one or more threads are running and the system required by these threads. Resources, generally speaking, Linux systems share program code and system function libraries between processes.

What commands are used to view and schedule processes?

Recommended: "linux tutorial"

Viewing and scheduling of processes The commands used respectively:

The commands to view the process are ps and top.

The commands for process scheduling include at, crontab, batch, and kill.

Related introduction:

The commands to view the process are ps and top.

ps command is used to view the currently running processes.

The commands for process scheduling include at, crontab, batch, and kill.

kill command

When you need to interrupt a foreground process, you usually use the < Ctrl c > key combination; but for a background process, it may not be solved by a key combination. , then you must resort to the kill command. This command can terminate background processes. There are many reasons for terminating a background process. Perhaps the process takes up too much CPU time; perhaps the process has died. Anyway, this happens often.

The kill command ends the process by sending a specified signal to the process. If no signal is specified, the default value is the TERM signal. The TERM signal will terminate any process that cannot catch the signal. As for those processes that can capture the signal, they may need to use the kill(9) signal, which cannot be captured.

The syntax format of the kill command is very simple. There are roughly two methods:

kill [-s signal | -p ] [ -a ] process number...

kill -l [Signal]

 -s specifies the signal to be sent. It can be either a signal name or a corresponding number.

-p specifies that the kill command only displays the pid of the process and does not actually send an end signal.

-l displays a list of signal names, which can also be found in the /usr/include/linux/signal.h file.

Use of kill command

Sometimes you may encounter a situation where a process has died or is idle, but cannot be killed by using the kill command. At this time, signal 9 must be sent to forcefully close the process. Of course, this "barbaric" method is likely to cause errors in opened files or data loss. Therefore, do not use forced termination unless absolutely necessary. If it doesn't even respond to signal 9, then I'm afraid the only option is to restart the computer.

nohup command

Theoretically, when we exit the Linux system, we will usually end all programs, including those background programs. But sometimes, for example, you are editing a long program, but you need to exit the system first when you get off work or have something to do. At this time, you do not want the system to end the program you have been editing for so long. You hope that the program can still be used when you exit the system. Continue execution. At this time, we can use the nohup command to make the process continue to execute after the user exits.

Generally, we let these processes execute in the background, and the results will be written to the nohup.out file in the user's own directory (you can also use output redirection to let it output to a specific document).

 [Example 26] $ nohup sort sales.dat &

This command tells the sort command to ignore that the user has exited the system, and it should run until the process is completed. Using this method, you can start a process that runs for days or even weeks, and the user does not need to log in while it is running.

The nohup command sends all output and error information of a command to the nohup.out file. If the output is redirected, only the error information is placed in the nohup.out file.

The above is the detailed content of What commands are used to view and schedule processes?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn