zoukankan      html  css  js  c++  java
  • 系统管理11-系统进程与计划任务管理 练习题

    1、通过ps命令的两种选项形式查看进程信息
    [root@localhost ~]# ps aux
    [root@localhost ~]# ps -elf
    2、通过top命令查看进程
    [root@localhost ~]# top
    top - 10:51:09 up  3:53,  3 users,  load average: 0.05, 0.04, 0.05
    Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem :  1867024 total,   100696 free,   752428 used,  1013900 buff/cache
    KiB Swap:  2097148 total,  2097100 free,       48 used.   859252 avail Mem
       PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                       
     13023 root      20   0  385624  19348  15268 S  0.7  1.0   0:25.04 vmtoolsd                      
       401 root      20   0       0      0      0 S  0.3  0.0   0:05.82 xfsaild/dm-0                  
    105237 root      20   0       0      0      0 S  0.3  0.0   0:00.39 kworker/0:2                   
    105272 root      20   0       0      0      0 S  0.3  0.0   0:00.09 kworker/0:3                   
    105281 root      20   0  157712   2272   1548 R  0.3  0.1   0:00.09 top                           
         1 root      20   0  128164   6916   4076 S  0.0  0.4   0:05.71 systemd                       
         2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd                      
         3 root      20   0       0      0      0 S  0.0  0.0   0:00.67 ksoftirqd/0                   
         5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H                  
         7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0                   
         8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh                        
         9 root      20   0       0      0      0 S  0.0  0.0   0:02.06 rcu_sched                     
        10 root      rt   0       0      0      0 S  0.0  0.0   0:00.25 watchdog/0                    
        12 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs                     
        13 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns                         
        14 root      20   0       0      0      0 S  0.0  0.0   0:00.01 khungtaskd                    
        15 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback                     
        16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd                   
        17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset                        
        18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kblockd                       
        19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 md                            
        25 root      20   0       0      0      0 S  0.0  0.0   0:00.24 kswapd0                       
        26 root      25   5       0      0      0 S  0.0  0.0   0:00.00 ksmd                          
        27 root      39  19       0      0      0 S  0.0  0.0   0:00.45 khugepaged                    
        28 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 crypto                        
        36 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kthrotld 
    3、通过pgrep命令查看sshd服务的进程号
    [root@localhost ~]# pgrep -l sshd
    1123 sshd
    105176 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
    ^C记录了713+0 的读入
    记录了713+0 的写出
    747634688字节(748 MB)已复制,2.15706 秒,347 MB/秒
    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 ~]#  dd if=/dev/zero of=/root/file bs=1M count=8190 &
    [2] 105341
    8、查看后台的任务列表
    [root@localhost ~]# jobs -l
    [1]+ 105321 停止                  dd if=/dev/zero of=/root/file bs=1M count=8190
    [2]- 105367 运行中               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 &
    [root@localhost ~]# jobs -l
    [1]+ 105389 运行中               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 ~]# pgrep -l dd
    2 kthreadd
    41 ipv6_addrconf
    13161 evolution-addre
    13181 evolution-addre
    105419 dd
    105430 dd
    [root@localhost ~]# kill -9 105419
    [root@localhost ~]# pgrep -l dd
    2 kthreadd
    41 ipv6_addrconf
    13161 evolution-addre
    13181 evolution-addre
    105430 dd
    [1]+  已杀死               dd if=/dev/zero of=/root/file bs=1M count=8190
    11、设置一次性计划任务在18:00时关闭系统,并查看任务信息
    [root@localhost ~]# at 18:00
    at> shutdown -h now
    at> <EOT>
    job 1 at Thu Aug  8 18:00:00 2019
    [root@localhost ~]# atq
    1 Thu Aug  8 18:00:00 2019 a root
    12、以root身份设置周期性计划任务
    a) 每天晚上的24点时打包压缩 /etc/passwd /etc/shadow /etc/group /etc/gshadow 为 file.tar.gz
    [root@localhost ~]# crontab -e
    0 0 * * * /bin/tar zcf  file.tar.gz /etc/passwd /etc/shadow /etc/group /etc/gshadow
    b) 每周一的每隔五分钟列 出磁盘使用状况
    */5 * * * 1 df -Th
    c) 每天的8:30与互联网时间同步服务器pool.ntp.org同步时间
    30 8 * * * /opt/httpdbak.sh
                             
    13、通过crontab命令查看root的计划任务,通过文件查看类工具列出/var/spool/cron下对应的文件内容
    [root@localhost ~]# crontab -l
    42 11 * * * /bin/tar zcf  file.tar.gz /etc/passwd /etc/shadow /etc/group /etc/gshadow 
    */5 * * * 1 df -Th
    30 8 * * * /opt/httpdbak.sh
    您在 /var/spool/mail/root 中有新邮件。
  • 相关阅读:
    Leetcode Excel Sheet Column Number
    AlgorithmsI PA2: Randomized Queues and Deques Subset
    AlgorithmsI PA2: Randomized Queues and Deques RandomizedQueue
    AlgorithmsI PA2: Randomized Queues and Deques Deque
    AlgorithmsI Programming Assignment 1: PercolationStats.java
    hdu多校第四场 1003 (hdu6616) Divide the Stones 机智题
    hdu多校第四场 1007 (hdu6620) Just an Old Puzzle 逆序对
    hdu多校第四场1001 (hdu6614) AND Minimum Spanning Tree 签到
    hdu多校第三场 1007 (hdu6609) Find the answer 线段树
    hdu多校第三场 1006 (hdu6608) Fansblog Miller-Rabin素性检测
  • 原文地址:https://www.cnblogs.com/elin989898/p/11327736.html
Copyright © 2011-2022 走看看