Program process thread
Procedure: stored in the external storage medium (such as a hard disk) static set of machine executable code and data.
Process: computer programs in a dynamic execution state of the CPU and memory.
Thread: The operating system can be the smallest unit of operation scheduling. It is included in the process, the actual operation of the unit process. A thread refers to a single control flow of a process sequence, a process can be complicated by a plurality of threads, each thread in parallel to perform different tasks.
The figure below, open a virtual machine host is a process, and during normal operation of the virtual machine, open will open a lot of services that it is to host a thread, a process can contain multiple threads.
View the process
ps-- view static process statistics
ps command is the most commonly used Linux system, often viewing tool, mainly used to display a static snapshot contains complete information about the processes currently running
a: Show all the process under the current terminal information
u: Use user-based format of the output process information
x: Displays the current user process information in all terminals
-e: show all processes within the information system
-l: long format process information
-f: use the full format process information
ps aux command
Wherein the meanings are as follows
ps -elf
Compared with aux show, add a few more, as shown meanings
PPID: parent process ID of the process, even if there is no parent process 0
C: CPU usage
PRI: the lower the process priority of the user status, the higher the level value ,,
NI: priority, the lower the kernel state value, the higher the level
ADDR: running, - indicates operation
WCHAN: process name in the kernel
top- view the process of dynamic information
top terminal command will display a full-screen interactive ranking process in the current interface, time tracking, including cpu, memory and other system resources occupancy, by default refreshed once every three seconds, and its role is similar to the Task Manager under the windows.
The following meanings
pgrep- query process information
When using a process PID ps query information, often require a combination of grep command to filter the output, so use very inconvenient, but it is pgrep command is used to query special tools specific process information.
Common options
-l displayed process name
-u user-specific queries
-t query processes running at a specific terminal
pstree- view the process tree
pstree Linux command to output the tree structure of each system process, more visually it determines the correlation between the respective processes
Common options
-a complete list of commands and information
-u Specifies the user
-p lists the PID number
Process control
Start the process
1 manual start
(1) Reception Start
Process running in the foreground, the user must wait until the end of the execution process and quit to continue to enter other commands
(2) back to start
Processes running in the background, it can input commands in the current terminal, without waiting for the end of the process for running time-consuming operation, coupled with the end of the command execution can &
2 scheduled to start the process
Scheduling start the process by setting at crontab command, at a command set for a one-off scheduled tasks, crontab to set periodic operation, scheduled to start scheduled tasks run in the background without taking up the customer's terminal command
(1)at
atq
Query plan task, the task has been executed will not appear in the list
atrrm
Deleted at the task, the task will not be deleted after execution, but the task is performed can not be deleted
(2) crontab
options
-e to edit the list of scheduled tasks
-u Specifies the scheduled task belongs to which user, for the current user default
-l displays a list of scheduled tasks
-r delete the list of scheduled tasks
Configuration format: minutes, hours, days, months, weeks as follows
After entering the same model and vim, enter the values
Change the course of operating mode
CTRL + Z: the process hangs, transferred to the background and stop execution
jobs-l view the background processes
fg: hanging into the background of the command transferred to the foreground
bg: to suspend execution of the command in the background, continues in the background
Termination process execution
When a user performs a process in the foreground, ctrl + c key combination traps, the tool can also be used to terminate kill, killall, pkill
kill
For the process could not be terminated properly, with force if necessary, terminate -9
killall
pkill
Use this command to name according to the process, a variety of attributes of the user running the process, the process where the terminals to terminate a particular process
Common options
-U specified user
-t Specifies the terminal