zoukankan      html  css  js  c++  java
  • 系统管理,一次性任务,周期任务

    1、通过ps命令的两种选项形式查看进程信息
    [root@localhost ~]# pa sux
    [root@localhost ~]# ps -efl
    2、通过top命令查看进程
    [root@localhost ~]# top
    3、通过pgrep命令查看sshd服务的进程号
    [root@localhost ~]# pgrep 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题命令操作调入到后台并暂停
    ^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=1024 &
    [2] 7975
    8、查看后台的任务列表
    [root@localhost ~]# jobs
    [1]+  已停止               dd if=/dev/zero of=/root/file bs=1M count=8190
    [2]-  运行中               dd if=/dev/zero of=/root/file bs=1M count=1024 &
    9、恢复dd if=/dev/zero of=/root/file bs=1M count=8190 让其在后台继续运行
    [root@localhost ~]# bg
    [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 ~]# jobs -ll
    [1]+  8182 运行中               dd if=/dev/zero of=/root/file bs=1M count=8190 &
    [root@localhost ~]# kill 8182
    11、设置一次性计划任务在18:00时关闭系统,并查看任务信息
    [root@localhost ~]# at 18:00
    at> init 0            
    at> <EOT>
    job 2 at Fri Aug  9 18:00:00 2019
    [root@localhost ~]# atq
    2 Fri Aug  9 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  *  *  *  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  *  *  *   ntpdate pool.ntp.org
    13、通过crontab命令查看root的计划任务,通过文件查看类工具列出/var/spool/cron下对应的文件内容
    [root@localhost ~]# crontab -l -u root
    0 0 * * * tar -zcf file.tar.gz /etc/passwd /etc/shadow /etc/group /etc/gshadow
    */5 * * * 1 df -Th
    30 8 * * * ntpdate pool.ntp.org
     ===========================================================
    [root@localhost ~]# tac /var/spool/cron/*
    30 8 * * * ntpdate pool.ntp.org
    */5 * * * 1 df -Th
    0 0 * * * tar -zcf file.tar.gz /etc/passwd /etc/shadow /etc/group /etc/gshadow
  • 相关阅读:
    记某农信社面试
    sublime2 c++的一些使用配置
    switch case
    sizeof与strlen的区别 浅谈
    求最大公约数
    Android基础控件——PopupWindow模仿ios底部弹窗
    Android基础控件——ListView实现时间轴效果
    Android基础控件——CardView的使用、仿支付宝银行卡
    Android基础控件——AlertDialog、ProgressDialog实现单选对话框、多选对话框、进度条对话框、输入框对话框
    Android基础——适配安卓6.0新权限系统
  • 原文地址:https://www.cnblogs.com/shenchunbo/p/11325432.html
Copyright © 2011-2022 走看看