linux "Nine" - the process of planning and task management

Content structure:

  • View the process

  • Process control

  • at a one-time task settings

  • crontab periodic task set


(A) view the process

Relations programs and processes

program

  • In the hard disk, an optical disk medium such as executable code and data

  • Static code saved

process

  • Program code running in memory and cpu

  • Dynamic code execution

  • Parent and the child

  •  Each process can create one or more processes

Thread

  • A process contains multiple threads

Process is a collection of threads

image.png

View static process statistics -ps command,

[Root @ localhost ~] # ps aux simple form display process information

  • a: View all the current process system

  • u: Specifies the user

  • x: The user process at all terminals (TTY) in ps / 0 remote terminal

[Root @ localhost ~] #ps -elf long display format information system processes


  • e: All

  • f: complete form

  • l: long form

View the dynamic processes ranking information -top (refresh once every three seconds)

Depending on the particular conditions of the query process PID command information -pgrep

[Root @ localhost /] # pgrep -l "log" to view details of the current user log-related processes

[Root @ localhost /] # pgrep -l -U test1 "bash" to view detailed information about the specified user process

Process information in a tree structure lists the command -pstree

[Root @ localhost /] # pstree -aup user to view the current process of tree

  • a: Show full information

  • u: list of usernames

  • p: PID number corresponding to the list

[Root @ localhost /] # pstree -ap test1 test1 user to view the properties of the specified process

(B) control process

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 of the scheduling process

Key combinations Ctrl + z

  • The current process is suspended and transferred to the background and stop execution

jobs command

  • View is in the background of the Task Manager (-l show details)

fg command

  • The recovery background process to the foreground, you can specify job numbers

bg command

  • Will resume a process running in the background and run

Ctrl + c key combination

  • Interrupt command being executed

kill,killall命令

  • kill PID to terminate the specified number of processes

  • killall用于终止指定名称的所有进程

  • -9选项用于强制终止

pkill命令

根据特定条件终止相应的进程

常用选项

  -U:根据进程所属用户名终止相应进程

  -t:根据进程所在的终端终止相应进程

(三)at 一次性计划任务设置

at命令

at [HH:MM] [yyyy-mm-dd] 小时:分钟  年-月-日

atq 查看当前系统计划任务

atrm 删除计划任务

Ctrl+d 提交任务


(四)crontab 周期性计划任务设置

crontab命令

  • 安装预先设置的时间周期(分,时,日,月,周)重复执行用户指定的命令操作

  • 属于周期性计划任务

  • 主要设置文件

       全局配置文件/etc/crontab

       系统默认的设置/etc/cron.*/

       用户定义的设置/var/spool/cron/用户名

image.png

image.png

管理cron计划任务

编辑计划任务

crontab -e [-u 用户名]

查看计划任务

crontab -l [-u 用户名]

删除计划任务

crontab -r [-u 用户名]





Guess you like

Origin blog.51cto.com/14475876/2432869