CentOS7服务管理
1、在/usr/lib/systemd/system目录下建立服务启动文件,文件格式:
[root@Centos7 ]# cat /usr/lib/systemd/system/nginx.service
[Unit] #该部分主要是对这个服务的说明,内容包括Description和After,Description用于描述服务,After用于描述服务类别
Description=Nginx service manager
#After=syslog.target network.target
#Conflicts=sendmail.service exim.service [Service] #该部分是服务的关键,是服务的一些具体运行参数的设置
Type=forking #后台运行服务
PIDFile=/application/nginx-1.14./logs/nginx.pid #文件名必需要与服务启动后产生的pid文件的文件名相同
# 如果"ExecStartPre="无"-"前缀的命令行执行失败,那么剩余的命令行将不会被执行,同时该单元将变为失败(failed)状态。 仅在所有无"-"前缀的 ExecStartPre= 命令全部执行成功的前提下,才会继续执行"ExecStart="命令
#ExecStartPre=-/application/nginx-1.14./sbin/nginx -s stop
ExecStartPre=/application/nginx-1.14./sbin/nginx -t
ExecStart=/application/nginx-1.14./sbin/nginx
ExecReload=/application/nginx-1.14./sbin/nginx -s reload
ExecStop=/application/nginx-1.14./sbin/nginx -s stop [Install]
WantedBy=multi-user.target
注意:[Service]部分的启动、重启、停止命令全部要求使用绝对路径,使用相对路径则会报错!
2、常用服务管理命令
修改或新增服务配置文件需要执行以下语句才能生效
systemctl daemon-reload
这时就可以利用systemctl管理服务
systemctl start|stop|reload nginx.service
systemctl cat nginx.service #查看服务配置文件
systemctl enable nginx.service #将服务添加到开机启动
systemctl disable nginx.service #关闭开机启动
参考链接:
https://blog.csdn.net/yuesichiu/article/details/51485147
https://www.cnblogs.com/duzhaoqi/p/7582404.html
CentOS7服务管理的更多相关文章
- centOS7服务管理与启动流程
centOS7服务管理与启动流程 centOS7启动流程 systemd简介 unit对象 unit类型 特性 service unit文件格式 service unit file文件通常由三部分组成 ...
- centos7 服务管理
服务脚本位置: /usr/lib/systemd/system (开机不登录就能够运行的服务) /usr/lib/systemd/user (用户登录后才能运行的服务) 服务脚本示例: [ ...
- CentOS7服务管理(重启,停止,自动启动命令)
我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体. systemctl is-enable ...
- linux的服务管理(centos6和Centos7)和网络管理(网卡配置),计划服务cron
服务和网络 管理 init ifcfg ens33 1.服务: Linux系统中提供的功能,统称为服务,如:at服务.cron服务.web服务.FTP服务.sshd服务等. 服务是由已经在运行的进程 ...
- centos7服务的管理
centos7上服务管理 author:headsen chen 2017-10-16 16:03:53 1,启动服务(每条都可以) systemctl start httpd ...
- Linux操作系统-CentOS7启动流程和服务管理
Linux操作系统-CentOS7启动流程和服务管理 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.systemd POST --> Boot Sequence --&g ...
- linux常用命令---centOS7的管理服务(针对yum安装的)
centOS7的管理服务(针对yum安装的)
- [Linux]服务管理:rpm包, 源码包
--------------------------------------------------------------------------------------------------- ...
- Linux之服务管理
一.计划任务 1) Crontab简介 1.Crontab是一个用于设置周期性被执行任务的工具: 2.被周期性执行的任务我们称为Cron Job: 3.周期性执行的任务列表我们称为Cron Table ...
随机推荐
- git之reset图解
https://blog.csdn.net/longintchar/article/details/81843048 1.三棵树. 此时如果我们运行 git status,会发现没有任何改动,因为现在 ...
- 创建 Visual Studio 2017 离线安装
代码示例: vs_Enterprise.exe --layout E:\VS2017LAYOUT --add Microsoft.VisualStudio.Workload.NetCoreTools ...
- Linux实战
1.root用户无法删除文件 [root@VM_0_9_centos .ssh]# lsattr authorized_keys ----i----------- authorized_keys ls ...
- Keepalived配置文件详解
global_defs { router_id LVS_$prio #节点唯一标识,通常为hostname } local_address_group laddr_g1 { ${lvs_node} # ...
- C#导出文本内容到word文档源码
将做工程过程中较好的代码片段珍藏起来,下面的代码内容是关于C#导出文本内容到word文档的代码,希望能对小伙伴们也有好处.<%@ Page Language="C#" Aut ...
- linux创建桌面快捷方式
这里拿postman举例,其他的程序类似 在/usr/sharp/applications新建postman.desktop文件(终端下输入vim /usr/sharm/applications/po ...
- 词云(wordcloud2.js js2wordcloud.js)
npm安装: npm install js2wordcloud --save 用法 var wc = new Js2WordCloud(document.getElementById('contain ...
- 对于SQL注入的理解
从网上搜索的资料,结合自己的理解整理了一下,网友们在查看时若有发现问题,还请不吝指正,谢谢! 1.什么是SQL注入? ——官方说法:把SQL命令插入到web表单验证的输入框中,提交到服务器,以达到越过 ...
- .babelrc和babel.config.js的相同配置不能合并
项目内部已经有了babel的配置文件babel.config.js module.exports = { presets: ["@vue/app"], }; 然后由于要按需引入el ...
- 求最近点对算法分析 closest pair algorithm
这个帖子讲得非常详细严谨,转一波. http://blog.csdn.net/lishuhuakai/article/details/9133961