zoukankan      html  css  js  c++  java
  • 进程与计划管理作业

    1、通过ps命令的两种选项形式查看进程信息
    [root@localhost ~]# ps aux
    [root@localhost ~]# ps -elf
    2、通过top命令查看进程
    [root@localhost ~]# top
    top - 10:42:56 up  2:13,  3 users,  load average: 0.00, 0.01, 0.05
    Tasks: 177 total,   1 running, 176 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  0.0 us,  6.2 sy,  0.0 ni, 93.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem :  1867024 total,    73908 free,   750376 used,  1042740 buff/cache
    KiB Swap:  2097148 total,  2097120 free,       28 used.   879064 avail Mem
    3、通过pgrep命令查看sshd服务的进程号
    [root@localhost ~]# pgrep -l sshd
    1092 sshd
    2692 sshd
    4、查看系统进程树
    [root@localhost ~]# pstree -aup
    5、使dd if=/dev/zero of=/root/file bs=1M count=8190 命令操作在前台运行
    [root@localhost ~]# dd if=/dev/zero of=/root/file bs=1M count=8190
    6、将第5题命令操作调入到后台并暂停
    [root@localhost ~]# dd if=/dev/zero of=/root/file bs=1M count=8190
    ^Z
    [1]+  已停止               dd if=/dev/zero of=/root/file bs=1M count=8190
    7、使dd if=/dev/zero of=/root/file2 bs=1M count=1024 命令操作在后台运行
    [root@localhost ~]# bg 1
    [1]+ dd if=/dev/zero of=/root/file bs=1M count=8190 &
    8、查看后台的任务列表
    [root@localhost ~]# jobs
    [1]+  运行中               dd if=/dev/zero of=/root/file bs=1M count=8190 &
    [root@localhost ~]# 记录了8190+0 的读入
    记录了8190+0 的写出
    8587837440字节(8.6 GB)已复制,8.74667 秒,982 MB/秒
    [1]+  完成                  dd if=/dev/zero of=/root/file bs=1M count=8190
    9、恢复dd if=/dev/zero of=/root/file bs=1M count=8190 让其在后台继续运行
    [root@localhost ~]# bg 1
    [1]+ dd if=/dev/zero of=/root/file bs=1M count=8190 &
    10、查询dd if=/dev/zero of=/root/file bs=1M count=8190 命令的进程并通过kill杀死
    [root@localhost ~]# dd if=/dev/zero of=/root/file bs=1M count=8190 &
    [1] 20251
    [root@localhost ~]# kill -9 20251
    [root@localhost ~]# jobs
    [1]+  已杀死               dd if=/dev/zero of=/root/file bs=1M count=8190
    [root@localhost ~]#
    11、设置一次性计划任务在18:00时关闭系统,并查看任务信息
    [root@localhost ~]# at 18:00
    at> shutdown -h
    at> <EOT>
    job 5 at Thu Aug  8 18:00:00 2019
    12、以root身份设置周期性计划任务
    a) 每天晚上的24点时打包压缩 /etc/passwd /etc/shadow /etc/group /etc/gshadow 为 file.tar.gz
    [root@localhost ~]# crontab -l -u root
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/passwd
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/group
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/gshadow
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/shadow
    b) 每周一的每隔五分钟列出磁盘使用状况
    [root@localhost ~]# crontab -l -u root
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/passwd
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/group
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/gshadow
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/shadow
    */5 * * * 1  df -Th
    */5 * * * 1  df -Th
    c) 每天的8:30与互联网时间同步服务器pool.ntp.org同步时间
    [root@localhost ~]# crontab -l -u root
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/passwd
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/group
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/gshadow
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/shadow
    */5 * * * 1  df -Th
    30 8 * * *  ntpbate pool.ntp.org
    13、通过crontab命令查看root的计划任务,通过文件查看类工具列出/var/spool/cron下对应的文件内容
    [root@localhost ~]# crontab -l -u root
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/passwd
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/group
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/gshadow
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/shadow
    */5 * * * 1  df -Th
    [root@localhost ~]#cat  /var/spool/cron/root
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/passwd
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/group
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/gshadow
    0 0 * * *  /etc/tar zcf file.tar.gz /etc/shadow
    */5 * * * 1  df -Th
  • 相关阅读:
    mybatis异常:org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.sunyan.domain.User
    Markdown首行缩进和换行
    mybatis入门——mybatis的概述
    python2跟python3的区别
    码云与git
    Python入门(一)
    python环境搭建
    python简介
    计算机基础
    Typora、安装及使用
  • 原文地址:https://www.cnblogs.com/CAPF/p/11321833.html
Copyright © 2011-2022 走看看