centos 服务开机启动设置
建立服务文件
以nginx 为例
vim /lib/systemd/system/nginx.service
在nginx.service 中插入一下内容
[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart= 服务启动命令
ExecReload= 服务重启命令
ExecStop=服务停止命令
PrivateTmp=true [Install]
WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
以754的权限保存在目录:/lib/systemd/system
设置开机自启动:
systemctl enable nginx.service
相关命令
功能 cnetos7以前 cnetos7
显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务 service nginx start systemctl start nginx.service 或 systemctl start nginx
停止某服务 service nginx stop systemctl stop nginx.service 或 systemctl stop nginx
重启某服务 service nginx restart systemctl restart nginx.service 或 systemctl restart nginx
使某服务自动启动 chkconfig --level 3 nginx on systemctl enable nginx.service 或 systemctl enable nginx
使某服务不自动启动 chkconfig --level 3 nginx off systemctl disable nginx.service 或 systemctl disable nginx
检查服务状态 service nginx status systemctl is-active nginx.service (仅显示是否 Active) systemctl status nginx.service (服务详细信息)
转载请注明出处:http://www.cnblogs.com/phpshen/p/6027407.html
centos 服务开机启动设置的更多相关文章
- CentOS程序 开机启动设置与chkconfig命令学习
CentOS设置程序开机启动的方法: 1.启动命令添加到/etc/rc.d/rc.local 文件中, 如: vim /etc/rc.d/rc.local #!/bin/sh # # This scr ...
- centos设置服务开机启动
Linux CentOS设置服务开机启动的方法 by 天涯 · 2013/07/26 CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别 在CentOS或者RedHa ...
- CentOS设置服务开机启动的方法
CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别在CentOS或者RedHat其他系统下,如果是后面安装的服务,如httpd.mysqld.postfix等,安装后 ...
- centos 6 与 centos 7 服务开机启动、关闭设置的方法
简单说明下 centos 6 与 centos 7 服务开机启动.关闭设置的方法: centos 6 :使用chkconfig命令即可. 我们以apache服务为例: #chkconfig --add ...
- (转)CentOS 7 sytemctl 自定义服务开机启动
CentOS 7 sytemctl 自定义服务开机启动 原文:http://blog.csdn.net/ithomer/article/details/51766319 CentOS 7继承了RHEL ...
- 【CentOS】centos7上查看服务开机启动列表
centos7上查看服务开机启动列表 命令: systemctl list-unit-files; 点击回车,可以向下翻页查询
- (转)CentOS下开机启动查看管理命令:chkconfig用法
CentOS下开机启动查看管理命令:chkconfig用法 CentOS下开机启动查看管理的命令是:chkconfig 1. 开机启动列表查看: chkconfig --list 说明 ...
- centos 7 开机启动配置
centos 7 开机启动 1 开机启动配置文件位于/usr/lib/systemd/system/ 2 nginx的配置[Unit]Description=nginx - high performa ...
- Redis加入Centos Linux开机启动
Redis加入Centos Linux开机启动 网上有很多redis在linux下自动启动的例子,实现的方式很多,很多都是参考一个老外流传出来启动的例子,其实直接使用是不行,而且有很多地方有一些语法错 ...
随机推荐
- BZOJ4443:[SCO2015]小凸玩矩阵
题目大意:给一个N*M的矩阵,选出N个数,使得每行没列只选一个数,求第K大的数的最小值是多少? 二分答案,第k大的数<=x,则有N-k+1个数<=k,用二分图判定. #include< ...
- 7.2.12. MySQL如何优化ORDER BY
在某些情况中,MySQL可以使用一个索引来满足ORDER BY子句,而不需要额外的排序. 即使ORDER BY不确切匹配索引,只要WHERE子句中的所有未使用的索引部分和所有额外的ORDER BY 列 ...
- C#编程之委托与事件四(一)【转】
C#编程之委托与事件(一) 本文试图在.net Framework环境下,使用C#语言来描述委托.事件的概貌.希望本文能有助于大家理解委托.事件的概念,理解委托.事件的用途,理解它的C#实现方 ...
- LeetCode Number of Connected Components in an Undirected Graph
原题链接在这里:https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ 题目: Giv ...
- java 向上转型 向下转型
//父类 四边形 class Quadrangle{ public static void draw (Quadrangle q){ } } //子类 public class Parallelog ...
- 深入浅出Docker(一):Docker核心技术预览
Docker是PaaS供应商dotCloud开源的一个基于LXC 的高级容器引擎,源代码托管在 GitHub 上, 基于Go语言开发并遵从Apache 2.0协议开源.Docker提供了一种在安全.可 ...
- win7系统如何安装SQL Server 2005
Microsoft Windows 7 旗舰版(32位) SQL Server 2005 简体中文开发板 方法/步骤 1 首先为了保证数据库的顺利安装,先启用IIS服务吧!Win7比XP好的一点是 ...
- MySQL字符编码
数据表tb的col列编码为latin1.而实际存储的字符是gbk编码时,用下面的语句可以查看到非乱码的原始字符串. select convert( binary(col) using gbk) fro ...
- sql server 中删除表中数据truncate和delete的区别(转载自.net学习网)
我们都知道truncate table可以用来删除整个表的内容,它与delete后面不跟where条件的效果是一样.但除此之外,我们还清楚它们之间有其它的区别吗?本章我们将一起讨论truncate与d ...
- 注解的基本盘点 -- 《Java编程思想》
注解(元数据)为我们在代码中添加信息提供了一种形式化的方法,使我们可以在之后的某一个时刻非常方便地使用这些数据. ---<Java编程思想> 其实注解可以理解为一个工具类,只要使用了这个工 ...