- Personal profile: Cloud computing network operation and maintenance professionals, understand operation and maintenance knowledge, master TCP/IP protocol, share network operation and maintenance knowledge and skills every day.
- Motto: The sea does not shy away from water, so it can become big; the mountain does not shy away from stones, so it can grow taller.
Personal homepage: Xiaolihui Technology's homepage
Table of contents
The relationship between programs and processes
The relationship between programs and processes
- Program: Executable codes stored in media such as hard disks and CDs, and codes in which data is statically stored
- Process: The program code running in the CPU and memory dynamically executes the code parent and child processes Each process can create one or more processes
command summary
- ps: View static process statistics ***
- top: View dynamic process ranking information
- pgrep command: query process PID information according to specific conditions
- pstree command: list process information in a tree structure
How the process is started
- Start manually:
- Start in the foreground: the user enters a command and executes the program directly
- Background start: add "&" symbol at the end of the command line
- Scheduling starts:
- Use the at command to set up a one-time scheduled task
- Use the crontab command to set up periodic scheduled tasks
Explanation of shortcut keys
Front and back scheduling of the process:
1>Ctrl+Z key combination: suspend the current process, that is, transfer it to the background and stop execution
2>jobs command: view the task list in the background
3>fg command: restore the background process to the foreground , you can specify the task number
kill, killall command:
1>kill is used to terminate the process with the specified PID number
2>killall is used to terminate all the processes with the specified name
3>-9 option is used to forcibly terminate
the Ctrl+C key combination to interrupt the ongoing process Order
Suspend the process: Ctrl+Z Force the process to terminate: kill -9
pkill command: terminate the corresponding process according to specific conditions
(-U: terminate the corresponding process according to the user name to which the process belongs
-t: terminate the corresponding process according to the terminal where the process is located)
at command: one-time scheduled task ***
(ctrl+D submit task) (atq: view atrm: delete)
crontab command: periodic scheduled task ***
(-e: edit scheduled task -l: view -r: delete)
The format of crontab task configuration: ***
minute+hour+date+month+week+command
field |
illustrate |
minute |
The value is any integer from 0 to 59 |
Hour |
The value is any integer from 0 to 23 |
date |
The value is any integer from 1 to 31 |
month |
The value can be any integer from 1 to 12 |
Week |
The value is any integer from 0 to 7, 0 or 7 represents Sunday |
Order |
command or program script to execute |
- *: Indicates any time within the range
- ,: Multiple discrete time points representing intervals
- -: Indicates a continuous time range
- /: The time frequency of the specified interval
Application example:
- 0 17 * * 1-5 Monday to Friday at 17:00 every day
- 30 8 * * 1,3,5 every Monday, Wednesday, and Friday at 8:30
- 0 8-18/2 * * * Every 2 hours between 8:00 and 18:00
- 0 * */3 * * every 3 days