Detailed planning process and task management (on-site practical exercises, can now do)

I heard a lot of small partners always wanted to learn how to get along well planned process and task management, this small series to demo it for you.

First, the process of viewing the spot drills

1. Display the current root user's static process (1)
wherein the USER refers to the current user; the PID is the process ID (PID 1 is init);% CPU,% MEN means cpu occupancy rate, memory usage; VSZ, RSS virtual memory, physical memory usage; TTY: (?? is unknown, mostly local load is) terminal; STAT: The current process state (S interruptible sleep process, D uninterruptible sleep process, s parent, <represents the priority high, R running processes, l representative of multiple linear low priority N, Z zombie, + foreground process); the sTART
is the start-up time; time: the process takes a total time of the CPU; Command: process name.
Detailed planning process and task management (on-site practical exercises, can now do)
Current static process root user 2. Check the system (Method 2)
View all current process displayed in full form long format systems ps -elf command.
UID, PID refers to the current user and the process ID; PPIDs is the parent of the current process (with ps aux command to see less); cpu occupancy is C (at this time is a sleep state, values are 0); PRI: user-mode priority (interactive and the process);
the NI: kernel mode (ranging from -20 to 19, the lower the value, the higher the priority); the horizontal line represents the running AddR; SZ: swap capacity occupied; WCHAN: process name in the kernel; STIME, TTY, TIME, and CMD function name and ps aux them consistent.
Detailed planning process and task management (on-site practical exercises, can now do)
3. Dynamic process display (3s refresh)
the list of names in the status bar consistent with previous (omitted); c key: cpu occupancy rate descending sort; m key: memory usage in descending order.
Detailed planning process and task management (on-site practical exercises, can now do)
4. query condition
(1) command "pgrep -l" log "" See
Detailed planning process and task management (on-site practical exercises, can now do)
(2) specifies the user to view, for example, see zhangsan process (login user is in the state provided zhangsan)
Detailed planning process and task management (on-site practical exercises, can now do)
5. Process query tree
(1) View tree structure to process display (clearly determine the relationship between parent and child)
command pstree -aup in a show all, u is the designated user, p is displayed PID
Detailed planning process and task management (on-site practical exercises, can now do)
(2) specifies the user: View user's tree structure zhangsan process
Detailed planning process and task management (on-site practical exercises, can now do)
(3) write-off zhangsan users, processes disappears
Detailed planning process and task management (on-site practical exercises, can now do)

Second, the process control field practice

1. First sr0 mount to the next mnt directory, copy the packages under mnt opt directory to the next, because the file size is 4.3G, the replication process time-consuming, at the end of the ampersand command, that this replication process to Background process. And the like without affecting the operation of other ifconfig command.
Detailed planning process and task management (on-site practical exercises, can now do)
Detailed planning process and task management (on-site practical exercises, can now do)
2. jobs -l command to view the process running in the background, that is, the copy operation is complete.
Detailed planning process and task management (on-site practical exercises, can now do)
3. Run the process of change
will suspend the current process, that is transferred to the background and stop execution: ctrl + Z;
restores background process to the foreground, assignable number: fg 1 (running in the background serial number 1);
Detailed planning process and task management (on-site practical exercises, can now do)

4. terminate process execution
forced termination process: Kill -9 39629 (PID number)
is used to terminate all processes with the specified name: killall -9 vim (vim terminate all processes)
Detailed planning process and task management (on-site practical exercises, can now do)
Detailed planning process and task management (on-site practical exercises, can now do)
The conditions of the process to terminate
the forced termination of all processes zhangsan users, That forced cancellation of the user's password interface back zhangsan
Detailed planning process and task management (on-site practical exercises, can now do)

Three, at a one-time task settings

1.首先用data获取实时时间,设置16:12的定时任务,任务设为定时统计当前所有进程的数量,并把数量写入ps文本当中,最后用ctrl + d组合键提交任务。
Detailed planning process and task management (on-site practical exercises, can now do)
2.查看定时一次性任务:atq命令
Detailed planning process and task management (on-site practical exercises, can now do)
3.再创建一个一次性任务,用atq查看到两个一次性任务。
Detailed planning process and task management (on-site practical exercises, can now do)
4.用atrm命令删除第二条任务
Detailed planning process and task management (on-site practical exercises, can now do)
5.当16:12时间点到了后,ps文本下即出现有进程的数量的统计:184
Detailed planning process and task management (on-site practical exercises, can now do)
6.当我们再次创建一次性任务,它的序列号变为3。
Detailed planning process and task management (on-site practical exercises, can now do)
TIP:一次性任务序列号为固定,不会因为1和2任务执行完成后,而将下一个创建的一次性任务标记为1或2,它的任务序列号是以递增数字为标记。

四、crontab 周期性任务设置

1.查看crontab配置文件
Detailed planning process and task management (on-site practical exercises, can now do)
2.低权限用户有些周期性任务无法执行(需考虑用户是否有权限去执行周期性任务),输入crontab -e编辑计划任务列表。
Detailed planning process and task management (on-site practical exercises, can now do)
3.来做一个测试,输入命令,使zhangsan目录下的数据文件在每天16:33时间点递归复制到opt目录下
Detailed planning process and task management (on-site practical exercises, can now do)
4.编辑完成后保存退出,命令“crontab -l”查看任务列表
Detailed planning process and task management (on-site practical exercises, can now do)
5.依照第一个任务格式编辑第二个周期性任务,命令“crontab -r”删除全部的周期性任务
Detailed planning process and task management (on-site practical exercises, can now do)
6.指定删除任务:进编辑任务单中用“dd”删除自己想要删除的整行任务

五、wget命令(从网上直接下载现成的软件包)

1.格式:wget 指定路径 //IP/软件包名称
接下来带领大家做个有趣的实验,在微软服务器上搭建一个ftp服务器,并且在ftp上放一个镜像文件,然后把这个镜像文件下载到Linux本地。类似从网站上下载镜像文件。
2.在微软服务器上教大家装一波ftp服务器,在窗口下进入选择服务管理器中
Detailed planning process and task management (on-site practical exercises, can now do)
3.点击添加角色和功能,添加服务器
Detailed planning process and task management (on-site practical exercises, can now do)
4.直接下一步
Detailed planning process and task management (on-site practical exercises, can now do)
5.直接下一步
Detailed planning process and task management (on-site practical exercises, can now do)
6.直接下一步
Detailed planning process and task management (on-site practical exercises, can now do)
7.勾选web服务器,点击下一步
Detailed planning process and task management (on-site practical exercises, can now do)
8.点击下一步
Detailed planning process and task management (on-site practical exercises, can now do)
9.点击下一步
Detailed planning process and task management (on-site practical exercises, can now do)
10.勾选FTP服务器,点击下一步
Detailed planning process and task management (on-site practical exercises, can now do)
11.点击安装
Detailed planning process and task management (on-site practical exercises, can now do)
12.待安装成功后,将系统防火墙关闭
Detailed planning process and task management (on-site practical exercises, can now do)
13.在Windows中运行最近添加的程序
Detailed planning process and task management (on-site practical exercises, can now do)
14.右击网站,点击添加FTP站点
Detailed planning process and task management (on-site practical exercises, can now do)
15.名称自取、路径放在E盘当中
Detailed planning process and task management (on-site practical exercises, can now do)

16.IP地址,选择无需验证,点击下一步
Detailed planning process and task management (on-site practical exercises, can now do)
17.勾选匿名、基本,给所有用户授权,给定读取
Detailed planning process and task management (on-site practical exercises, can now do)
18.在e盘的site目录下拉进来一个镜像
Detailed planning process and task management (on-site practical exercises, can now do)
19.在宿主机上用浏览器浏览网址
Detailed planning process and task management (on-site practical exercises, can now do)
20.试着ping通192.168.195.137,发现可以连通
Detailed planning process and task management (on-site practical exercises, can now do)
21.输入命令,下载软件包,并且保存在当前用户的家目录下
Detailed planning process and task management (on-site practical exercises, can now do)

本章计划总结

* 熟练使用查看进程的命令(ps、top、pgrep、pstree)

* 记住控制进程命令(ctrl + Z组合键、jobs、bg、fg)

* 牢牢掌握终止进程命令(kill、killall、pkill)

* 熟练设置at命令设置计划任务

* 熟练掌握crontab计划任务的配置过程

Guess you like

Origin blog.51cto.com/14475593/2432503