常用命令

描述                                 旧命令            新命令

使服务自动启动           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)后每次开启此服务自动启动,无需人工启动

CentOS linux7 设置开机启动服务的更多相关文章

  1. CentOS 7设置开机启动服务,添加自定义系统服务

      由于版本的迭代,最近刚刚接触 CentOS 7,各种蛋疼 发现跟以前用的CentOS 6有着一些本质上的差别,连启动服务都不会启动了,一怒之下自己找资料,于是有了这篇文章... 1.建立服务文件 ...

  2. centos 7 设置开机启动服务

    2018-12-25 Centos7下添加开机自启动脚本和服务的方法 以docker 服务为例 1.centos7自带命令设置 systemctl enable docker.service 2.设置 ...

  3. (转) CentOS 7添加开机启动服务/脚本

    CentOS 7添加开机启动服务/脚本 原文:http://blog.csdn.net/wang123459/article/details/79063703 一.添加开机自启服务 在CentOS 7 ...

  4. Linux的运行级别和设置开机启动服务的方式

    Linux的运行级别 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是从0到6,具有不同的功能.这些级别定义在/ect/inittab文件中.这个文件是init程序寻找 ...

  5. ubuntu下设置开机启动服务

    原文:http://blog.csdn.net/dante_k7/article/details/7213151 在ubuntu10.04之前的版本都是使用chkconfig来进行管理,而在之后的版本 ...

  6. CentOS 6.3开机启动服务及自动联网

    虚拟机设置选择NAT模式,默认情况下,CentOS不是自动连接上网的,要点击右上角有个电脑图标,选择system eth0进行连接, 可以修改开机启动配置只需修改:/etc/sysconfig/net ...

  7. CentOS 7添加开机启动服务/脚本

    一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以 jenkins 为例):systemctl enable jenkins.service #设置jenkins服 ...

  8. windows系统下同时启动三台Tomcat服务的配置&并设置开机启动服务

    1.tomcat 7.0.82下载地址:链接:https://pan.baidu.com/s/1i51pAgl 密码:mxol 2.解压apache-tomcat-7.0.82-windows-x64 ...

  9. CentOS 7添加开机启动服务脚本

    一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务 ...

随机推荐

  1. 【转】Selenium-WebDriverApi接口详解

    浏览器操作 # 刷新 driver.refresh() # 前进 driver.forward() # 后退 driver.back() 获取标签元素 # 通过ID定位目标元素 driver.find ...

  2. LeetCode_169. Majority Element

    169. Majority Element Easy Given an array of size n, find the majority element. The majority element ...

  3. Delphi中动态加载TreeView信息

    unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  4. asp.net下Response.ContentType类型汇总

    在ASP.NET中使用Response.ContentType="类型名";来确定输出格式 'ez' => 'application/andrew-inset', 'hqx' ...

  5. 【Leetcode_easy】700. Search in a Binary Search Tree

    problem 700. Search in a Binary Search Tree 参考1. Leetcode_easy_700. Search in a Binary Search Tree; ...

  6. webstrom报错 缺少JSCS 怎么解决

  7. VS2010调试warning MSB8012:路径不匹配问题

    VS2010调试warning MSB8012:路径不匹配问题 调试信息如下: warning MSB8012: TargetPath(D:\J2KCodecSDK\Samples\C++\a_Eas ...

  8. Linux 学习笔记 1 使用最小的系统,从分区安装系统开始

    我们常用的linux系统在安装过程中大多都省略了对系统进行分区的操作,以至于后期,不了解什么是分区以及分区当中最基本的一些概念, 我们不说最细的知识,只求了解这个过程,那直接步入正题,开始第一节的学习 ...

  9. csu 1898: 复盘拉火车

    1898: 复盘拉火车 Submit Page   Summary   Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 114    ...

  10. Windows 10系统快捷键

    虚拟桌面 创建新的虚拟桌面:Win + Ctrl + D 关闭当前虚拟桌面:Win + Ctrl + F4 切换虚拟桌面:Win + Ctrl +左/右 任务视图:Win + Tab Win10常用W ...