1. Trang chủ
  2. » Công Nghệ Thông Tin

Topic 3.3 Process Management

6 6 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 430,61 KB
File đính kèm Topic3.3_ProcessManagement.rar (419 KB)

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Triển khai một máy tính làm việc Linux với các tính năng về đồ họa, vi tính văn phòng,… Hệ thống vận hành: cài đặt, cấu hình, quản trị, xử lý sự cố,… Vận hành hệ điều hành Linux: cài đặt, cấu hình mạng, máy trong, sử dụng thành thạo các công cụ quản lý mạng, cấu hình nhân, DFS, lập kế hoạch cho việc lưu trữ và phục hồi dữ liệu, TCP IP , config device,… Liên kết cơ bản kỹ năng đến Internet: kết nối, email, bảo mật, DNS, Apache, SSH, NTP,…

Trang 1

Quản lý tiến trình

1 Theo dõi các tiến trình

Tạo user nv1, nv2

ps -ax xem thông tin tất cả các tiến trình

PID: process ID

PPID: Parent process ID

PROCESS STATE CODES

Here are the different values that the s, stat and state output specifiers

(header "STAT" or "S") will display to describe the state of a process

D Uninterruptible sleep (usually IO)

R Running or runnable (on run queue)

S Interruptible sleep (waiting for an event to complete)

T Stopped, either by a job control signal or because it is being traced

W paging (not valid since the 2.6.xx kernel)

X dead (should never be seen)

Z Defunct ("zombie") process, terminated but not reaped by its parent

For BSD formats and when the stat keyword is used, additional characters may

be displayed:

< high-priority (not nice to other users)

N low-priority (nice to other users)

L has pages locked into memory (for real-time and custom IO)

s is a session leader

l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)

+ is in the foreground process group

Alt+f2 login root

Trang 2

70 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[root@localhost ~]# pstree -np | more

init(1)-+-udevd(415)-+-udevd(1740)

| `-udevd(1742)

|-auditd(1248) -{auditd}(1249)

|-rsyslogd(1264)-+-{rsyslogd}(1267)

| `-{rsyslogd}(1268)

|-rpcbind(1306)

|-dbus-daemon(1321) -{dbus-daemon}(1324)

|-NetworkManager(1333)

|-modem-manager(1339)

|-avahi-daemon(1345) -avahi-daemon(1346)

|-rpc.statd(1363)

|-wpa_supplicant(1428)

|-rpc.idmapd(1429)

#ps -ef | more xem tiến trình cha, con

Ý nghĩa các cột

■ UID: The user responsible for launching the process

■ PID: The process ID of the process

■ PPID: The PID of the parent process (if a process is started by another process)

■ C: Processor utilization over the lifetime of the process

■ STIME: The system time when the process started

■ TTY: The terminal device from which the process was launched

■ TIME: The cumulative CPU time required to run the process

■ CMD: The name of the program that was started

xem thông tin các tiến trình theo cấu trúc cây:

pstree -np | more

Trang 3

|-acpid(1443)

|-hald(1452) -hald-runner(1453)-+-hald-addon-inpu(1493)

| `-hald-addon-acpi(1499)

[root@localhost ~]# pstree -np | more

………

|-abrtd(1650)

|-abrt-dump-oops(1658)

|-qpidd(1669)-+-{qpidd}(1670)

|-crond(1707)

|-atd(1718)

|-login(1731) -bash(2024) -pstree(2250)

|-login(1733) - bash(2057 ) -mc(2089)-+-cons.saver(2090)

|-login(1735) -bash(2115) -mc(2227)-+-cons.saver(2228)

[root@localhost ~]# ps -u u1

PID TTY TIME CMD

2057 tty2 00:00:00 bash

2089 tty2 00:00:00 mc

2090 ? 00:00:00 cons.saver

2091 pts/5 00:00:00 bash

Theo dõi tiền trình login của u1, u2

Alt+F2, login u1; chạy mc

Alt+F3, login u3; chạy mc

Hoặc:

[root@localhost ~]# pstree -nup | more

ps -u u1 xem thông tin tiến trình u1 khởi tạo

Hủy tiến trình theo PID

kill PID

[root@localhost ~]# pkill 2089 # 2089 là PID của mc do u1 khởi rạo

Hủy tiến trình theo tên

pkill named hoặc

killall processes by name

[root@localhost ~]# pkill mc

Lệnh killall: được dùng khi muốn kill tất cả các process với tên chắc chắn Lúc này không cần dùng

ps để tìm PID Ví dụ: # killall httpd

[root@localhost ~]# pgrep sendmail #tìm pid của sendmail

[root@localhost ~]# pkill sendmail #hủy tiến trình sendmail

[root@localhost ~]# pgrep sendmail #tìm pid của sendmail

khởi động lại sendmail

[root@localhost ~]# service sendmail start

Trang 4

72 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[root@localhost ~]# jobs

[1]+ Stopped mc

[2] Running sleep 1000 &

[3]- Running sleep 1500 &

2 Nhận dạng tiến trình

Tiến trình tiền cảnh: do user tạo ra và giao tiếp trực tiếp với user

vd: mc

Tiến trình hậu cảnh: (deamon process)

- do người dùng tạo ra

- do hệ thống tạo ra, nó tự động kích hoạt

Đưa 1 tiến trình vào hậu cảnh

- Chạy mc, nhấn Ctrl+Z

Hoặc thêm & vào sau câu lệnh

[root@localhost ~]# sleep 1000 &

[root@localhost ~]# sleep 1500 &

Xem các tiến trình trong hậu cảnh

Lệnh bg %n : chạy tính trình trong hậu cảnh

Lệnh fg %n : đưa tiến trình ra tiền cảnh

3 Theo dõi performance của hệ thống

Lệnh top

Key Switches For The Top Command:

-h - Show the current version

-c - This toggles the command column between showing command and program name -d - Specify the delay time between refreshing the screen

-o - Sorts by the named field

-p - Only show processes with specified process IDs

-u - Show only processes by the specified user

-i - Do not show idle tasks

Trang 5

Xem thông số CPU:

us percent cpu being used by userland code

sy percent cpu being used by kernelspace code

ni like "us" but related to "niced" processes

id idle

wa cpu is idle because it waits for IO to complete

hi interrupts generated by hardware

si interrupts generated by software

Các trạng thái:

w: S Process Status

The status of the task which can be one of:

'D' = uninterruptible sleep

'R' = running

'S' = sleeping

'T' = traced or stopped

'Z' = zombie

Trang 6

74 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

Ý nghĩa các cột

PID: The process ID of the process

USER: The user name of the owner of the process

PR: The priority of the process

NI: The nice value of the process

VIRT: The total amount of virtual memory used by the process

RES: The amount of physical memory the process is using

SHR: The amount of memory the process is sharing with other processes

S: The process status (D = interruptible sleep, R = running, S = sleeping, T = traced or stopped, or Z = zombie)

%CPU: The share of CPU time that the process is using

%MEM: The share of available physical memory the process is using

TIME+: The total CPU time the process has used since starting

COMMAND: The command line name of the process (program started)

Xuất kết quả lệnh top ra file:

top -cSb -n 1 > proc.txt

Có thể sử dụng tiện ích htop để xem và kiểm soát các tiến trình

Ngày đăng: 27/09/2022, 02:23

w