• CentOS linux7 设置开机启动服务


    常用命令

    描述                                 旧命令            新命令

    使服务自动启动           chkconfig --level 3 http on    systemctl enable 服务名.service    systemctl enable httpd.service

    使服务不自动启动       chkconfig --level 3httpd off   systemctl disable 服务名.sevice

    查看服务章台                service httpd status                      systemctl status httpd.service        systemctl is-active httpd.service

    查看所有已启动的服务  chkconfig --list                              systemctl  list-units --type=service

    启动服务                      service httpd start                          systemctl start httpd.service

    停止服务                      service httpd stop                           systemctl stop httpd.service

    重启服务                      service httpd restart                        systemctl restart httpd.service

    1 、把服务设置成系统服务

    a、找到系统服务目录、systemd/system(假如有多个此目录,可通过目录下是否有.service文件来判断是否)

    b、新建文件,假如需要把tomcat加入到服务中,则新建tomcat.service    #touch tomcat.service

    c、文件中输入必要信息,vi tomcat.service,如下:

    [Unit]  

    Description=nginx   #描述

    After=network.target  #服务类别

    [Service]  

    Type=forking  #运行形式

    ExecStart=/xx/xx start  #注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

    ExecReload=/xx/xx restart  注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

    ExecStop=/xx/xx  stop  注意:[Service]的启动、重启、停止命令全部要求使用绝对路径

    PrivateTmp=true  #表示给服务分配独立的临时空间

    [Install]  

    WantedBy=multi-user.target  #服务安装的相关设置,可设置为多用户

    d、设置后保存

    e、设置成开机自启动(systemctl enable tomcat.service)后每次开启此服务自动启动,无需人工启动 

  • 相关阅读:
    各地电信运营商插广告赚钱,北京联通也不甘落后
    也谈Server Limit DOS的解决方案
    Still Believe
    无奈小虫何
    好朋有也有类别
    无为而治
    青鸟随想
    落寞时分
    网站开发学习路线和资料
    C++实例 添加快捷键表
  • 原文地址:https://www.cnblogs.com/xianhaiyan/p/7650391.html
Copyright © 2020-2023  润新知