linux processes and scheduled tasks


Progress of the program and scheduled tasks

 

One. View and control processes

程序:是保存在外部存储介质(如硬盘、光盘)中的可执行机器代码和数据的静态集合。
进程:是在CPU及内存中处于动态执行状态的计算机程序。

1. Review the process of command

(1)PS命令 ---查看静态的进程统计信息

-a # Show information about all processes currently terminal
-u # use user-based format output
-x # processes the current user information of the terminal at all
-e # all processes within the system information
-l # long format process information
-f # use the full format process information
alone execute ps # displays only the current user session open process
performed, for example: ps -aux
Here Insert Picture Description

上述信息每段的含义如下:
 - USER:启动该进程的用户账号名称
 - PID:该进程在系统中的数字ID号
 - TTY:表面该进程在哪个终端运行。“?”表示未知或不需要终端
 - STAT:显示进程当前状态,S休眠、R运行、Z僵死、<高优先级、N低优先级、s父进程、+前台进程
 - START:启动该进程的时间
 - TIME:该进程占用的CPU时间
 - COMMAND:启动该进程的命令的名称
 - %CPU:CPU占用的百分比
 - %MEN:内存占用的百分比
 - VSZ:占用虚拟内存(swap空间)的大小
 - RSS:占用常驻内存(物理内存)的大小

(2)TOP ---查看当前进程动态信息
P # to occupy the CPU by percentage
M # according to the proportion of the sort memory
#kill out process corresponding to K
H help #
q # normal exit top
Here Insert Picture Description

上述系统任务(Tasks)信息为:
 - total:总进程数
 - running:正在运行的进程数
 - sleeping:休眠的进程数
 - stopped:中止的进程数
 - zombie:僵死无响应的进程数
 - PU占用信息:
 - us:用户占用
 - sy:内核占用
 - ni:优先级调度占用
 - id:空闲CPU
 - wa:I/O占用
 - hi:硬件中断占用
 - si:软件中断占用
 - st:虚拟化占用
内存占用(Mem)信息:
 - total:总内存空间
 - userd:已用内存
 - free:空闲内存
 - buffers:缓冲区域
交换空间(Swap)占用:
 - Total:总交换空间
 - Used:已用交换空间
 - Free:空闲交换空间
 - Cached:缓存空间

(3)pgrep ---按条件查询进程
-l # query process name and PID
-U # query a specific user process
-t # query process in particular operation of the terminal
(4) pstree - see the process tree
-p # corresponding PID numbers listed
-u # corresponding list username
-a # complete list of command information
Here Insert Picture Description

2. Process Control

start up:

“&”操作符: 挂后台
Here Insert Picture Description
- copy a file to the image file aaa inside, due to the large data, using the "&" linked to the background.
   Ctrl + Z # the process of being transferred to the background and execute suspend
   bg # will resume suspended tasks run in the background
   fg # restore the background to the foreground task

Inquire:

   View daemon jobs #

termination:

   Ctrl + C # Traps foreground process (common)
   the kill PID number # binding process to terminate the process -9 forced termination
   killall # terminate multiple processes with the same name -9 forced termination
   pkill # terminated in accordance with the process name, user attributes such
   -U # specified user
   -t # specified terminal,

two. Plan task management

(1)一次性任务设置 ---at
Here Insert Picture Description
Provided that the atd service system to start
① the current system time to be confirmed by DATE
② set in 16:40 minutes July 13, 2019 of
③ at> tasks performed
④ ctrl + D to submit the task
atq # Query Settings task
atrm # delete the task set
(2)周期性任务设置 ---crontab 前提条件是cron系统服务要启动
-e # edit list of scheduled tasks (the same as the operation vi)
-u # specify the user
-l # list shows scheduled tasks
-r # delete the scheduled tasks list (delete all)
in a nutshell is performed repeatedly:
the format : minutes, hours, days, months, weeks
Here Insert Picture Description

以上表示在每个月每个星期每天的17:05分执行reboot命令。

  • "*" Indicates any time
  • "-" indicates a continuous-time range
  • "Represents a range of discrete interval"
  • "/" Column frequency as the specified interval date field / * represents every 3 days to 3
    (3) Note the timing task
    is preferably end with a regular scheduled task "> / dev / null 2> & 1"
  • ">" Redirects
  • "/ Dev / null" character special device file, Blackhole equipment or null device
    intended to prevent a large number of output log spam.
Published 10 original articles · won praise 6 · views 571

Guess you like

Origin blog.csdn.net/J_031591/article/details/103960422