当前位置:网站首页>Process and scheduled task management
Process and scheduled task management
2022-06-13 08:20:00 【wf19880114】
Catalog
1. The relationship between program and process
2.ps View static process information
3.top View dynamic process information
4.pgrep Query the process according to specific conditions PID Information
5.pstree: List process information in a tree structure
3. Front and back scheduling of processes
4. Terminate the running of a process
3、 ... and . Set up scheduled tasks
1.at command : Set up a one-time scheduled task
One , process
1. The relationship between program and process
Program ( static state ):
Save on hard disk , Executable code and data in media such as CD ; Statically saved code .
process ( dynamic ):
stay CPU And the program code running in memory ,
Dynamically executed code ; Father child process ( Each program can create one or more processes )
【 Program : Binary files , static state 】
【 process : The process of running a program , Is dynamic , It has life cycle and operation state , Concurrent multiple threads , Each thread performs a different task 】
Program , process , Thread relationship :
Threads are contained in the process , Is the actual operation unit in the process , It is also the basic unit that can run independently in the operating system , Also known as lightweight process , Multiple threads can be concurrent in one process , Each thread can perform different tasks in parallel , The processes in the task manager are generated by the downloaded application , An application can also contain multiple processes .
2.ps View static process information
ps command : View static process statistics
1)ps -aux: The process information will be displayed in the form of a simple list
-a: All process information under the current terminal
-u: Output process information in user oriented format
-x: Process information of the current user under all terminals
In the above output information , The first line is the title of the list , The meaning of each field is described as follows .
USER: The name of the user account that started the process .
PID: The number of processes in the system ID Number , It's the only one in the current system .
%CPU:CPU Percentage occupied .
%MEM: Percentage of memory used .
vsz: The amount of virtual memory used by the process (KB).
RSS: The amount of physical memory consumed by the process (KB).
TTY: Indicates which terminal the process is running on . Processes that are not started from the terminal are shown as ?.
Jane said :
pts It's a remote login terminal ctrl+ALT F1-F6 tty1 Image interface 2 and 6
Character interface ? The process executed by the system itself
Open a terminal , This terminal is called pts/0, If you open another terminal , This new terminal is called pts /1.
STAT: The state of the process (D: Non interruptible sleep state :R: Running state ;s : In a dormant state , Can be awakened ;
T: Stop state , It may be suspended in the background or the process is in trace debugging state :
z: Zombie process , The process has been aborted , But some programs are still in memory )
D: System daemons
T: mode 、 Program execution generally stops
R: The program is currently in operation , Or it can be operated ;
s : The program is currently sleeping ( It can be said that idle Status !), But some signals (signal) Wake up the .
T: The program is currently detecting or stopping ;
Z: The program should have terminated , But his father's program can't stop him normally , cause zombie Jiang Zang corpse )
The status of the program
D Non interruptible state .
They mean the following ::
<: Indicates that the process is running at a high priority
N: Indicates that the process is running at a low priority
L: Indicates that the process has pages locked in memory
s: Indicates that the process is the controlling process
l: Indicates that the process is multithreaded
+: Indicates that the current process is running in the foreground
D: System daemons
T mode 、 Program execution generally stops
START: Time to start the process .|
TIME: The cPU Time .
COMMAND: The name of the command that started the process
2)ps -elf : The process information in the system will be displayed in long format
-e: Display all process information in the system .
-1: Use long format to display process information .
-f: Display process information in full format .
3.top View dynamic process information
top command : View dynamic process information
top command - View process dynamic information
In the above output information , The beginning section shows the system tasks (Tasks ) 、CPu Occupy 、 Memory footprint (Mem)、 Swap empty
between (Swap) And so on , Remit . The ranking of the current process is displayed under the general information . The meaning of relevant information is expressed as follows
uptime
13:22:30 current time
up 20days System running time , Indicates that this server is running continuously 20 days
user Number of currently logged in users
load average:0.06,0.60,0.48 System load , That is, the average length of the task queue . The three values are 1 minute 、5 minute 、15 The average from minutes ago to now .
System tasks (Tasks) Information :
total, The total number of processes ;
running, Number of running processes ;
sl Number of dormant processes ;
stopped, Number of processes aborted ;
zombie, The number of dead and unresponsive processes .
CPU Occupancy information :
us, User occupied ;
sy, Kernel occupancy ;
ni, Priority scheduling occupies ;
id, Free cPU;
wa,I/o Waiting for occupation ;
hi, Hardware interrupt occupation ;
si, Software interrupt occupancy ;
st, Virtualization takes up . Learn about the free cPU percentage , It mainly depends on %id part .
Memory footprint (Mem) Information :
total, Total memory space ;free, Free memory ;used, Used memory ;
buff/ cache, The sum of memory and physical buffers .
Swap space (Swap) Occupy :
total, Total swap space ;
free, Free swap space ;
used, Used swap space ;
avail Mem, Available physical space .
4.pgrep Query the process according to specific conditions PID Information
-l: Option to output the corresponding process name and PID
-U: Option to query the processes of a specific user
-t: Option to query the processes running on a specific terminal
5.pstree: List process information in a tree structure
-p: When using this option, you can list the corresponding PID Number
-u: Option to list the corresponding user names
-a: Option to list complete command information
Two , Process startup mode :
1. Manual start
The front desk starts : The user enters the command , Direct execution
Background start : Add... At the end of the command line "&" operator
【jobs -l: View the task list running in the background 】
2. Scheduling start
at command : Set up a one-time scheduled task
crontab command : Set up periodic planning tasks
3. Front and back scheduling of processes
ctrl+Z: Suspend the current process , That is to call into the background and stop execution
jobs: View the list of tasks in the background
fg: Restore the background process to the foreground , Task sequence number can be specified
4. Terminate the running of a process
When a user executes a process in the foreground , Can press Ctrl+C The key combination forces an interrupt ( If the command is not responded for a long time ).
After interrupting the operation of the foreground process , The system will return to the command line prompt state and wait for the user to enter a new command . When the Ctrl+C When a key combination cannot terminate a program or needs to end a process running on another terminal or in the background , You can use a special process termination tool kill、killall and pkill.
kill -15 The signal simply tells the corresponding process to proceed " Security 、 Clean exit ", After the program receives the signal , It's usually done before you quit " preparation ", Such as the release of resources 、 Temporary file cleaning and so on , If the preparation is done , And then terminate the program . however , If in " preparation " In the process , Block or other problems cause failure to succeed , Then the application can choose to ignore the termination signal . That's why we sometimes use kill There is no way to order " Kill " Reason for application , Because the default kill The signal is SIGTERM(15), and SIGTERM(15) Can be blocked and ignored .
Compared with kill -15 command ,kill -9 When executed , There's no time for the app " preparation " Of , So it usually has side effects , Data loss or terminal failure to recover to normal state .
3、 ... and . Set up scheduled tasks
1.at command : Set up a one-time scheduled task
2.crontab command : Set up periodic planning tasks
The periodic plan task is modified once , It needs to be rebooted .
Four 、 summary
View process commands (ps、top、pgrep、pstree)
Process control ( Start the process 、 Scheduling process 、 Terminate the process )
at Command to set scheduled tasks
crontab The configuration field of the scheduled task
边栏推荐
- Remote office solution under epidemic situation
- How to modify desktop path in win10 system
- About redis encapsulation tool class using distributed locks
- HCIP_ Static experiment
- Common shell script development specifications
- 1. fabric2.2 comprehensive learning - Preface
- Do not update the sub component page of parameter object passed from parent to child of nailing applet?
- 母婴用品批发行业使用管理软件提高效率 实现降本增效
- Redis interview questions
- Altium Designer中导入和导出设置的方法
猜你喜欢
What software can be used to solve the problems faced by the auto parts industry
HCIP_ MGRE comprehensive experiment
Microservice system architecture construction I: Environment Construction
The method of SolidWorks modifying text font in engineering drawing
How about a well-known food material distribution information management system?
使用kvm创建三台能通局域网的虚拟机
How to efficiently manage commodities and inventory in the beverage wholesale industry
Openharmony notes ----------- (I)
酒水批发行业应当如何高效管理商品与库存
Methods of importing and exporting settings in Altium Designer
随机推荐
MySQL sorts according to the specified order of the specified fields
P7712 [Ynoi2077] hlcpq
Dest0g3 520迎新赛
ERP基础数据 金蝶
Edge浏览器如何安装BdTab(BD)新标签页插件(图文教程)
Determine whether a string is rotated from another string
Redis interview questions
第115页的gtk+编程例子——最简单的进度条2附带使用Anjuta写gtk程序的步骤
[game theory complete information static game] Application of Nash equilibrium
Local shooting range 2- file upload vulnerability (III) - Network Security
Sizeof, strlen find character length
When submitting the laravel admin form and using the required verification, an error is reported when the value is 0
Do not update the sub component page of parameter object passed from parent to child of nailing applet?
Penetration problem (main directory, password explosion, database uploading Trojan horse)
SolidWorks修改工程图中文字字体的方法
【完全信息静态博弈-Nash均衡的特性】
Reverse order and comparison of strings
File upload question type
Install cuda+cusp environment and create the first helloword starter project
汽配行业面临的难题用什么软件帮忙解决呢