zoukankan      html  css  js  c++  java
  • 服务管理

    服务管理:
    启动类型:手动,自动,禁用
    #查看所有服务
    [root@localhost yuq]# systemctl list-unit-files
    #查看所有service服务
    [root@localhost yuq]# systemctl list-unit-files --type service
    #查看sshd服务
    [root@localhost yuq]# systemctl is-active sshd
    active
    #查看ftp服务
    [root@localhost yuq]# systemctl is-active vsftpd.service
    active
    #关闭ftp服务
    [root@localhost yuq]# systemctl stop vsftpd.service
    [root@localhost yuq]# systemctl is-active vsftpd
    unknown
    #开启ftp服务
    [root@localhost yuq]# systemctl start vsftpd
    #查看服务当前状态
    [root@localhost yuq]# systemctl is-active vsftpd
    active
    #重启ftp服务
    [root@localhost yuq]# systemctl restart vsftpd
    #查看是否开机启动
    [root@localhost yuq]# systemctl is-enabled vsftpd.service
    disabled
    #关闭开机自动启动(不会影响当前状态)
    [root@localhost yuq]# systemctl disable vsftpd
    #设置开机自动启动(不会影响当前状态)
    [root@localhost yuq]# systemctl enable vsftpd.service
    [root@localhost yuq]# systemctl is-active vsftpd
    active
    #禁用服务
    [root@localhost yuq]# systemctl mask vsftpd.service
    ln -s '/dev/null' '/etc/systemd/system/vsftpd.service'
    #查看服务状态
    [root@localhost yuq]# systemctl status vsftpd
    vsftpd.service
    Loaded: masked (/dev/null)
    Active: active (running) since 二 2017-06-13 13:12:19 CST; 11min ago
    Main PID: 5615 (vsftpd)
    CGroup: /system.slice/vsftpd.service
    └─5615 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
    #禁用后服务不能启动
    [root@localhost yuq]# systemctl start vsftpd
    Failed to issue method call: Unit vsftpd.service is masked.
    #解禁服务
    [root@localhost yuq]# systemctl unmask vsftpd.service
    #查看服务状态
    root@localhost yuq]# systemctl status vsftpd
    vsftpd.service - Vsftpd ftp daemon
    Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
    Active: active (running) since 二 2017-06-13 13:12:19 CST; 16min ago
    Main PID: 5615 (vsftpd)
    CGroup: /system.slice/vsftpd.service
    └─5615 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
    #启动服务
    [root@localhost yuq]# systemctl start vsftpd

    #服务定义的脚本
    [root@localhost yuq]# ls /usr/lib/systemd/system

    #搜索服务
    [root@localhost yuq]# systemctl list-unit-files |grep vsftpd

    #自定义服务脚本
    #安装服务
    [root@localhost yuq]# rpm -ivh copuloa*
    #复制脚步
    [root@localhost yuq]# cp cpuload1.service cpuload2.ervice /usr/lib/systemd/system
    #查询服务
    [root@localhost yuq]# systemctl list-unit-files | grep cpuload
    #启动服务
    [root@localhost yuq]# systemctl start cpuload1

  • 相关阅读:
    Docker 使用Docker创建MySQL容器
    Javascript 转Date对象为字符串实现函数
    Jenkins 实现Gitlab事件自动触发Jenkins构建及钉钉消息推送
    Sysbench 使用总结
    ElementUI Dialog 结合Vue实现对话框body“二分”布局
    Element FORM结合Vue实现横向排列表单项
    Vue 插槽之插槽内容学习总结
    Vue 基于VSCode结合Vetur+ESlint+Prettier统一Vue代码风格
    Pytest Pytest源码分析
    Vue 中引用第三方js总结
  • 原文地址:https://www.cnblogs.com/ytb-wpq/p/7000729.html
Copyright © 2011-2022 走看看