1. 程式人生 > >Day14-1 日常運維 3

Day14-1 日常運維 3

tab 表示範圍 進程間通信 pat 編輯 不讓 ima mount chkconfig

  • 任務計劃
    /etc/crontab 任務計劃配置文件
    技術分享圖片
    crontab -e 編輯任務計劃
    crontab -l(小寫的L) 列出任務計劃
    crontab -r 刪除
    crontab -u [username] 指定某個用戶
    1-5 表示範圍1到5
    1,2,3 表示或者

    • /2 表示能被2整除的
      要保證服務的啟動狀態 systemctl start crond.servive
      /var/spool/cron/[username] 用戶的cron計劃內容
  • 系統管理chkconfig
    技術分享圖片
    技術分享圖片
    --level 34 network off/on 控制network的等級3和4開關
    --add [servicename] 增加一行服務,前提是在/etc/init.d/目錄下有文件

    --del [servicename] 刪除一行服務

    1. 系統管理systemd
      systemctl list-units --all --type=service 列service清單
      技術分享圖片
      systemctl enable [servicename] 讓服務開機啟動
      systemctl disable [servicename] 不讓開機啟動
      systemctl status [servicename] 查看服務狀態
      systemctl stop [servicename] 停止服務
      systemctl start [servicename] 啟動服務
      systemctl restart [servicename] 重啟服務
      systemctl is-enabled [servicename] 檢查服務是否開機啟動

    /usr/lib/systemd/system/ 系統所有unit,分為以下類型
    技術分享圖片
    技術分享圖片
    service 系統服務
    target 多個unit組成的組
    device 硬件設備
    mount 文件系統掛載點
    automount 自動掛載點
    path 文件或路徑
    scope 不是由systemd啟動的外部進程
    slice 進程組
    snapshot systemd快照
    socket 進程間通信套接字
    swap swap文件
    timer 定時器

    systemctl list-units 列出所有正在運行的unit
    systemctl list-units --all 列出所有

    systemctl list-units --all --state=inactive 列出不在運行的unit
    systemctl list-units --type=service 列出在運行的service
    systemctl is-active [servicename] 查看某個服務是否為active

    target
    系統為了方便管理,用target來管理unit
    systemctl list-unit-files --type=target
    systemctl list-dependencies multi-user.target 查看這個target下有什麽unit
    systemctl get-default 獲取默認target
    systemctl set-default multi-user.target 設置默認target
    一個service屬於一種類型的unit
    多個unit組成了一個target
    一個target裏面包含了多個service

  • Day14-1 日常運維 3