Linux System Management 10--process and scheduled task management

Source: Internet
Author: User
Tags terminates

Linux System Management -Process and scheduled task management a , the relationship between procedures and processes

1. Procedure

• Executable code and data saved on hard disk, CD-ROM and other media

• Statically saved code

2. Process

• program code running in CPU and in memory

• Dynamically executed code

• Parent, child process: each process can create one or more processes

two , To view process statistics at rest PS Command

1.ps aux command

(1) function: Show process information as a simple list

(2) Explanation of options:

A: Displays all process information under the current terminal, including the processes of other users

U: Output process information in a user-oriented format

X: Displays process information for the current user under all terminals

(3) Example:

2.ps-elf command

(1) function: Displays process information in a long format and contains richer content

(2) Explanation of options:

-E: Displays all process information in the system

-L:display process information in long format

-F:displaying process information using the fullformat

(3) Example:

3. Direct use of PS command

When you directly execute a PS command without any options , only the processes that are open in the current user session are displayed

4. View details of a process

(1)PS aux|grep "process name"

(2)ps-elf|grep " process name "

three , dynamically viewing process statistics top Command

1, the role:thetop command will be in the current terminal in a full-screen interactive interface to display the process ranking, timely tracking including CPU, memory and other system resource consumption, by default, three seconds to refresh, by default to the CPU occupancy rate is sorted.

2. Common options:

-D: Specify the interval between refreshes, in seconds

-B: Operation in batch mode, generally with- n simultaneous use

-N: Specifies the number of times the loop is displayed

-U: Specify user name

-P: Specify the process number

3. Examples of use of each option:

(1)top-d Specify the time interval for refresh

[[email protected] ~]# top-d 5 "Specify a refresh Interval of 5 seconds"

(2)top-b-N Specifies the number of cycles to display simultaneously in batch mode operation

Omit some of the content here

Omit to end here

Note: When CPU usage is too high, you should not directly perform the top command view, you can save the information in a file to view, so that the CPU A high occupancy rate causes a crash. Operation is as follows

(3)top-u Specify user name

(4)top-p Specify process number

4. Common Interactive Commands

P: Sort based on Percentage of CPU usage (this is sorted by default)

M: Sort based on the size of the resident memory

T: Sort by cumulative time

K: Terminate a process

Q: Exit the program

R: Reschedule the priority level of a process (-20~19)

5. Explanation:

Top-16:58:24 "Current system Time"

1:54 "System has been running for 1 hours minutes"

2 users "currently logged in 2 user"

Load average:0.00,0.00,0.00 "System average load:1 minutes,5 minutes,15 minutes of "

Tasks:108 Total "task:108 General process"

1 Running "1 processes are running"

107 sleeping "107 process Sleep"

0 stoppd "0 process stops"

0 Zombie "0 Zombie processes (freeze process)"

CPU (s): 0.0%us "user control consumes CPU percentage"

0.0%sy "CPU percentage consumed by kernel space "

0.0%ni "CPU percent of processes that have changed priority within the user Process Control "

100.0% "Idle CPU percent"

0.0%wa "Percentage of CPU time waiting for input and output "

0.0% hi ""

0.0%si ""

Men: 1012352k Overall "total physical memory 1012352k"

465816k used "uses 465816k of physical Memory"

546536k free 546536k of physical memory

61064k buffe "61064k as kernel cache"

Swap: 2031608k Total "swap partition totals 2031608k"

0k used "swap partition not used"

2031608k free "Idle swap partition total 2031608k"

267580k cache "Buffered swap partition total 267580k"

PID: Process number

User: Username for process owner

PR: Priority

NI: Nice value. Negative values indicate high priority, positive values indicate low priority

VIRT: Total amount of virtual memory used by the process, in kilobytes

RES: The amount of physical memory that the process used, not swapped out, in kilobytes

SHR: Shared memory size, in kilobytes

S: Process status

%CPU: CPU time consumption percentage last updated to current

%MEM: Percentage of physical memory used by the process

time+: Total CPU timeused by the process , Unit 1/100 sec

Command: Commands

Four , Viewing process information

1.pgrep command

(1) function: query PID information according to specific conditions

(2) Common options:

-L: Show process name

-U: Specify a specific user

-T: Specify terminal

(3) Example:

2.pstree command

(1) Role: Listing process information in a tree-shaped structure

(2) Common options:

-A: Show full information

-U: List the corresponding user name

-P: list the corresponding PID number

(3) Example:

Five , how processes are started

1, manual start:

(1) reception start: User input command, direct execution program

(2) background start: Add "&" symbol at the end of the command line

Example

(3) Pre-and post-stage scheduling of processes

1>ctrl+z suspends the current process, which is called into the background and stops execution

2>jobs command to view the list of tasks in the background, plus- l displays the PID number simultaneously

The 3>FG command restores the background process to the foreground to run, specifying the task program number

4>BG command to set the background paused process to run in the background

Example

(4) operation of the termination process

1>ctrl+c interrupt a command being executed

2>kill,killall command

Kill The process that terminates the specified PID number

Killall All processes used to terminate a specified name

-9 option to force termination

Example:

3>pkill Command

• Role: Terminate the process according to specific conditions

• Common options:

-U: Terminates the process based on the user name the process belongs to

-T: Terminates the process based on the terminal where the process resides

Example:

2 scheduled start

(1) use the AT command to set a one-time task schedule

1> Service script:/etc/init.d/atd

2> format:at[hh:mm] [YYYY-MM-DD] Set the task schedule for the day without date

3> Basic Operation:

Ctrl+d Save Exit

ATQ querying an existing one-time task schedule

ATRM [ task Sequence ] Delete the first few tasks

4> Example

"set in today's 18:40 : Count the number of processes running by the root user in this point-in-time system and save the value to /tmp/ps.root in the file "

"set in 5 months on the dateof the year: Auto Power off"

"Set seven days after 22:00 Auto Power off"

"Set up tomorrow night 22:00 restart httpd service "

(2) use the crontab command to set up recurring scheduled Tasks

1> script Name:/etc/init.d/crond

2> main configuration files:

• Global configuration file:/etc/crontab

• System default settings:/etc/cron.*/

• User-defined settings:/var/spool/cron/ user name

3> managing cron Scheduled Tasks

• Edit:crontab-e [-u user name ]

• View:crontab-l [-u user name ]

• Delete:crontab-r [-u user name ]

Note:the-u option is available only to the root user

4>crontab The format of the task configuration

a special representation method of 5> time value

* Indicates any time within the range

, which represents multiple discontinuous points of time for the interval

-Represents a continuous range of time

/Specify the time frequency of the interval

Example:

7:50 automatically open sshd every morning ,22:50 off

Empty the FTP Server Bulletin directory every 5 days /var/ftp/pub

Restart httpd service every Saturday

one, three or five weekly 17:30 packaged backup /etc/httpd directory

[Email protected] ~]# CRONTAB-E

Note: The command recommends using absolute paths

Linux System Management 10--process and scheduled task management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.