当前位置:网站首页>Process and planned task management
Process and planned task management
2022-07-27 23:22:00 【Pupils with a bad stomach】
Program : Binary , static state /bin/date,/usr/sbin/sshd
process : It's the process of running the program , dynamic , It has life cycle and operation state .

1、 The relationship between program and process
Program
- Save on hard disk 、 Executable code and data in media such as CD
- Code stored statically in a file
process
- stay CPU And the program code running in memory
- Dynamically executed code
- Father 、 Subprocesses
- Each program can create one or more processes
2、 Planning task management crontab2-1
crontab command
- According to the preset time period ( minute 、 Hours 、 God .......) Repeat the user specified command operation
- It belongs to periodic plan
- Main settings file
- Global profile , Located in file :/etc/crontab
- System default location , Located in the directory :/etc/cron.*/
- User defined settings , Located in file :/var/spool/cron/ user name
3、 Planning task management crontab2-2
management crontab Planning tasks
- Edit scheduled task
crontab -e [ user name ]
- View scheduled tasks
crontab -l [-u user name ]
- Delete scheduled task
crontab -r [-u user name ]
4、crontab The format of task configuration 2-1

| Field | explain |
| minute | The value is from 0 To 59 Any integer between |
| Hours | The value is from 0 To 23 Any integer between |
| date | The value is from 1 To 31 Any integer between |
| month | The value is from 1 To 12 Any integer between |
| week | The value is from 0 To 7 Any integer between ,0 perhaps 7 On behalf of Sunday |
| command | Command or program script to execute |

5、crontab The format of task configuration 2-2
Special representation of time value
- * This is an arbitrary range of time
- , Represents multiple discontinuous time points of an interval
- - Represents a continuous time range
- / Specify the time and frequency of the interval
Application example
- 0 17 * * 1-5 Monday to Friday... Every day 17:00
- 30 8 * * 1,3,5 Every Monday 、 3、 ... and 、 Five 8 spot 30 branch
- 0 8-18/2 * * * 8 Point to 18 Between every point 2 Hours
- 0 * */3 * * Every time 3 God
6、 Thread state
1. newly build (NEW): A new thread object is created .
2. Can run (RUNABLE): After the thread object is created , Other threads ( such as main Threads ) Called the object's start() Method . The thread in this state is in the runnable thread pool , Waiting to be selected by thread scheduling , obtain cpu Right to use .
3. function (RUNNING): Operational state (runnable) The thread of the cpu Time slice (timeslice), Execute program code .
4. Blocking (BLOCKED): Blocking state refers to the thread giving up for some reason cpu Right to use , That is to say, to give up cputimeslice, Stop running temporarily . Until the thread becomes runnable (runnable) state , To have another chance to get cpu timeslice Go to run (running) state . There are three types of obstruction :
- Waiting for a jam : function (running) Thread execution of o.wait() Method ,JVw The thread will be put into the waiting queue (waitting queue) in .
- Synchronous blocking : function (runing) When the thread of gets the synchronization lock of the object , If the synchronization lock is held by another thread , be JVWM The thread will be put into the lock pool (lockpool) in .
- Other blockages : function (running) Thread execution of Thread.sleep (longms) or t.join() Method , Or send out 1/o When asked ,Jvw It puts the thread in a blocking state . When sleep () Status timeout 、join() Wait for the thread to terminate or timeout 、 perhaps I/o When it's done , The thread goes back to runnable (runnable) state .
5. Death (DEAD): Threads run () 、 main () Method execution ends , Or quit because of an exception run() Method , The thread ends its life cycle . Dead threads cannot be regenerated
7、ps Command to view static process statistics
TTY : terminal
Common parameters
- -a: Display all process information under the current terminal , Include other users' processes . And "x" When the options are combined, all process information in the system will be displayed .
- -u: Output process information in user oriented format .
- -x: Display the process information of the current user under all terminals .
Common option combinations
ps -aux # The process information will be displayed in the form of a simple list

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 ?.
STAT: The state of the process (D: Non interruptible sleep state :R: Running state ;s: In a dormant state , Can be awakened ; Four : 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 、 The execution of the program generally stops
- R: The program is currently in operation , Or the town is 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
8、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 space (Swap) And so on , The following shows the ranking of the current process
- System tasks (Tasks) Information : total, The total number of processes ;running, Number of running processes ;sleeping, 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/0, 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 Men, Available physical space .
- %CPU Last updated to now CPU Percentage of time used
- %MEM Percentage of physical memory used by the process
- TIME+ Used by process cPU Total time , Company 1/100 second
- COMMAND Command name / Command line

top Command full screen operation interface shortcut key :
Default 3s Refresh once , Press s Modify the refresh time, press space : Refresh now .
- P: Press cPU Sort
- M: Sort by memory T: Sort by time
- p: Process worker e, View the status of a process N Key according to the start time to sort the number keys 1: Show the... For each kernel cPU Usage rate
- u/Uu: Specify the user to display
- h: You can get top Online help information for the program q: Jian can exit normally top Program
notes : If through top The ranking tool finds a process cPT The occupancy rate is very high , The process needs to be terminated , Can be in top Press... In the operation interface k key , Then... Will appear at the top of the list "PID to signal/kill [default pid =3180]:" A reminder of , Enter... Of the specified process according to the prompt PID Sign and press Enter key , appear "send pid 5597signal [15/sigterm]" Prompt information for secondary confirmation of , Then press Enter Press OK to terminate the corresponding process .


边栏推荐
- jvm组成及内存模型
- Gstore weekly gstore source code analysis (V): log tracking of security mechanism
- 【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
- On data management of data warehouse
- MySQL的B+Tree索引到底是咋回事?聚簇索引到底是如何长高的?
- 2022年五大网络管理趋势
- Redis网红高频面试题三连:缓存穿透?缓存击穿?缓存雪崩?
- Exam summary on May 31, 2022
- Visual display method of machine learning project
- 2022/3/22 examination summary
猜你喜欢

Desai wisdom number - other charts (parallel coordinate chart): family's willingness to allocate assets in the future

Safety foundation 2

Leetcode-461. Hamming distance

Quartus:Instantiation of ‘sdram_ model_ plus‘ failed. The design unit was not found.

看GAN如何一步步控制图像生成风格?详解StyleGAN进化过程

浅析云原生应用安全组织架构

Solve the problem that the last bit of IP address access is odd and even, or even and odd (the problem encountered when the cloud encryption machine connects to the cloud server, the whole process is

微信安装包11年膨胀575倍,UP主:“98%的文件是垃圾”;苹果应用商店被曝大量色情App;四大科技巨头呼吁废除闰秒|极客头条

Deploy dolphin scheduler high availability cluster based on rainbow

You don't know about redis. Let me explain the underlying data structure of redis in detail
随机推荐
Kubevera deploys applications through cli
Understanding and use of third-party library
Real time Bi (III) technical implementation of offline data and real-time data processing
On data management of data warehouse
Www 2019 | Han: heterograph attention network
网络开发套接字以及UDP、TCP协议
Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
在所有浏览器中禁用带有元 HTML 标记的缓存
XML 外部实体 (XXE) 漏洞及其修复方法
2022/4/8 exam summary
只会Excel想做图表可视化,让数据动起来?可以,快来围观啦(附大量模板下载)
Arm32进行远程调试
Cloud native enthusiast weekly: a complete collection of client go examples
The security dilemma of software supply chain faced by enterprises
【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码
Jupyter notebook solves the problem that printing information cannot be viewed after closing the browser
Interviewer: I can't carry a backpack at all. Are you going by yourself or I'll give you a lift?
[noi2018] return (Kruskal reconstruction tree / persistent and search set)
leetcode-470.用 Rand7() 实现 Rand10()
Simple and practical data visualization cases