Processes and scheduled tasks Task Management
1, the relationship between the program and the process of
(1) program
- In the hard disk, an optical disk medium such as executable code and data
- Static code saved
(2) process
- Program code running in CPU and memory
- Code dynamically executed
- Parent and the child: Every process can create one or more processes
2, static view process information
[root@localhost ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.3 56640 6672 ? Ss 00:22 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 24
root 2 0.0 0.0 0 0 ? S 00:22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 00:22 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 00:22 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S 00:22 0:00 [migration/0].
(1)
- USER: name of the user account to start the process.
- PID: The process PID number in the system, is unique in the current system.
- % CPU: The percentage of CPU usage.
- % MEM: The percentage of memory usage.
- VSZ: occupancy size of the virtual memory swap space.
- RSS: occupy permanent memory size of physical memory.
- TTY: indicates that the processes are running on which terminal. "?" Represents the unknown or no terminal.
- STAT: it shows the current status of the process: D: non-interrupted sleep, S: interruptible sleep, R: ready or running state, T: a suspended state, the Z: zombie state <: high-priority process, N: Low Priority level process, +: the foreground process group of the process, |: first session of the process: multi-threaded process, s
- START: Start time of the process.
- TIME: The process of CPU time.
- COMMAND: name of the command to start the process.
(2) stat state
- S: uninterruptible sleep
- R: can interrupt sleep
- Z: Ready or running
- <: Advanced finite process
- N: low-priority process
- +: The foreground process group of the process
- T: suspend state
- Z: dead state
3, dynamic process view
top - 00:51:38 up 28 min, 1 user, load average: 0.00, 0.01, 0.03
Tasks: 399 total, 2 running, 397 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 2035356 total, 1760020 free, 134140 used, 141196 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 1751724 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
722 root 20 0 0 0 0 S 0.3 0.0 0:00.10 xfsaild/dm-0
1 root 20 0 56640 6672 3888 S 0.0 0.3 0:01.31 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/0
- top - 16:58:24 [the current system time]
- [1:54 system has been running 1 hour 54 minutes]
- 2 users currently logged in [2] Users
- load average: 0.00,0.00,0.00 [System load average: 1 minute, 5 minutes, 15 minutes]
- Tasks: 108 total [tasks: 108 total process]
- 1 running [1] running processes
- 107 sleeping the sleep process [107]
- 0 stoppd process stops [0]
- [0 0 zombie zombie process (freezing process)]
- Cpu (s): 0.0% us user control of CPU [percentage]
- 0.0% sy [kernel space occupied by the percentage of CPU]
- 0.0% ni [priority processes within the user process control changed occupancy percentage of CPU]
- CPU idle percentage of 100.0% []
- 0.0% wa [percentage of CPU time to wait for the input and output]
- 0.0% hi 【】
- 0.0% and 【】
- Men: 1012352k total amount of physical memory 1012352k []
- 465816k used [used] 465816k physical memory
- 546536k free physical memory [of] free 546536k
- [61064k 61064k buffe used as the kernel cache]
- Swap: 2031608k total amount of swap partition 2031608k []
- 0k used [not] use the swap partition
- 2031608k free [total] swap free 2031608k
- 267580k cache swap buffer [total] 267580k
- PID: Process ID
- USER: User name of the process owner
- PR: Priority
- NI: nice value. A negative value indicates a high priority, positive values indicate a low priority
- VIRT: total amount of virtual memory used by the process in kb
- RES: process used, not swapped out of physical memory size, unit kb
- SHR: shared memory size in kb
- S: Process Status
- % CPU: the last update to the current occupancy percentage of CPU time
- % MEM: The percentage of physical memory used by the process
- TIME +: Total CPU time used by the process, units of 1/100 sec
- COMMAND: command
4, the process was started
(1) manual start:
- Reception Start: user input commands directly execute the program
- Start backstage: Add the "&" symbol at the end of the command line
Front and back scheduling (2) process
- Ctrl + Z suspends the current process, that is transferred to the background and stop execution
- jobs command to view the list of tasks in the background, at the same time add -l displays the PID number
- fg command will restore the background process to the foreground, you can specify the number of job program
- bg command will pause the background processes running in the background adjusted
Run (4) to terminate the process
- Ctrl + C interrupt command being executed
- kill、killall 命令
- kill PID to terminate the specified number of processes
- killall terminates all processes for the specified name
- -9 option forcibly terminated
5, scheduled to start
(1) use the at command, set the time schedule
- Service script: /etc/init.d/atd
- Formatting: at [HH: MM] [yyyy-mm-dd] to set the day's task plan it does not add date
- Basic operation:
- Ctrl + D to save and exit
- atq query the existing time schedule
- atrm [task number] Delete the first several tasks
(2) use the crontab command to set periodic scheduled tasks
- Script Name: /etc/init.d/crond
- The main configuration file:
- Global configuration file: / etc / crontab
- Cron task management plans
- Edit: crontab -e [-u username]
- View: crontab -l [-u username]
- Delete: crontab -r [-u username]
- Special value representing time
- * Indicates any time within this range
- A plurality of discrete time points, the interval represented by
- - indicates a continuous range of time
- / Frequency specified time interval
1, the relationship between the program and the process of
(1) program
- In the hard disk, an optical disk medium such as executable code and data
- Static code saved
(2) process
- Program code running in CPU and memory
- Code dynamically executed
- Parent and the child: Every process can create one or more processes
2, static view process information
[root@localhost ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.3 56640 6672 ? Ss 00:22 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 24
root 2 0.0 0.0 0 0 ? S 00:22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 00:22 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 00:22 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S 00:22 0:00 [migration/0].
(1)
- USER: name of the user account to start the process.
- PID: The process PID number in the system, is unique in the current system.
- % CPU: The percentage of CPU usage.
- % MEM: The percentage of memory usage.
- VSZ: occupancy size of the virtual memory swap space.
- RSS: occupy permanent memory size of physical memory.
- TTY: indicates that the processes are running on which terminal. "?" Represents the unknown or no terminal.
- STAT: it shows the current status of the process: D: non-interrupted sleep, S: interruptible sleep, R: ready or running state, T: a suspended state, the Z: zombie state <: high-priority process, N: Low Priority level process, +: the foreground process group of the process, |: first session of the process: multi-threaded process, s
- START: Start time of the process.
- TIME: The process of CPU time.
- COMMAND: name of the command to start the process.
(2) stat state
- S: uninterruptible sleep
- R: can interrupt sleep
- Z: Ready or running
- <: Advanced finite process
- N: low-priority process
- +: The foreground process group of the process
- T: suspend state
- Z: dead state
3, dynamic process view
top - 00:51:38 up 28 min, 1 user, load average: 0.00, 0.01, 0.03
Tasks: 399 total, 2 running, 397 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 2035356 total, 1760020 free, 134140 used, 141196 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 1751724 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
722 root 20 0 0 0 0 S 0.3 0.0 0:00.10 xfsaild/dm-0
1 root 20 0 56640 6672 3888 S 0.0 0.3 0:01.31 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/0
- top - 16:58:24 [the current system time]
- [1:54 system has been running 1 hour 54 minutes]
- 2 users currently logged in [2] Users
- load average: 0.00,0.00,0.00 [System load average: 1 minute, 5 minutes, 15 minutes]
- Tasks: 108 total [tasks: 108 total process]
- 1 running [1] running processes
- 107 sleeping the sleep process [107]
- 0 stoppd process stops [0]
- [0 0 zombie zombie process (freezing process)]
- Cpu (s): 0.0% us user control of CPU [percentage]
- 0.0% sy [kernel space occupied by the percentage of CPU]
- 0.0% ni [priority processes within the user process control changed occupancy percentage of CPU]
- CPU idle percentage of 100.0% []
- 0.0% wa [percentage of CPU time to wait for the input and output]
- 0.0% hi 【】
- 0.0% and 【】
- Men: 1012352k total amount of physical memory 1012352k []
- 465816k used [used] 465816k physical memory
- 546536k free physical memory [of] free 546536k
- [61064k 61064k buffe used as the kernel cache]
- Swap: 2031608k total amount of swap partition 2031608k []
- 0k used [not] use the swap partition
- 2031608k free [total] swap free 2031608k
- 267580k cache swap buffer [total] 267580k
- PID: Process ID
- USER: User name of the process owner
- PR: Priority
- NI: nice value. A negative value indicates a high priority, positive values indicate a low priority
- VIRT: total amount of virtual memory used by the process in kb
- RES: process used, not swapped out of physical memory size, unit kb
- SHR: shared memory size in kb
- S: Process Status
- % CPU: the last update to the current occupancy percentage of CPU time
- % MEM: The percentage of physical memory used by the process
- TIME +: Total CPU time used by the process, units of 1/100 sec
- COMMAND: command
4, the process was started
(1) manual start:
- Reception Start: user input commands directly execute the program
- Start backstage: Add the "&" symbol at the end of the command line
Front and back scheduling (2) process
- Ctrl + Z suspends the current process, that is transferred to the background and stop execution
- jobs command to view the list of tasks in the background, at the same time add -l displays the PID number
- fg command will restore the background process to the foreground, you can specify the number of job program
- bg command will pause the background processes running in the background adjusted
Run (4) to terminate the process
- Ctrl + C interrupt command being executed
- kill、killall 命令
- kill PID to terminate the specified number of processes
- killall terminates all processes for the specified name
- -9 option forcibly terminated
5, scheduled to start
(1) use the at command, set the time schedule
- Service script: /etc/init.d/atd
- Formatting: at [HH: MM] [yyyy-mm-dd] to set the day's task plan it does not add date
- Basic operation:
- Ctrl + D to save and exit
- atq query the existing time schedule
- atrm [task number] Delete the first several tasks
(2) use the crontab command to set periodic scheduled tasks
- Script Name: /etc/init.d/crond
- The main configuration file:
- Global configuration file: / etc / crontab
- Cron task management plans
- Edit: crontab -e [-u username]
- View: crontab -l [-u username]
- Delete: crontab -r [-u username]
- Special value representing time
- * Indicates any time within this range
- A plurality of discrete time points, the interval represented by
- - indicates a continuous range of time
- / Frequency specified time interval