在CentOS 7上利用systemctl添加自定义系统服务
每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install],具体内容如下:
[Unit]
Description=*****
After=network.target
[Service]
Type=forking
PIDFile=*****
ExecStart=*****
ExecReload=*****
ExecStop=*****
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[Unit]部分主要是对这个服务的说明,内容包括Description和After,Description用于描述服务,After用于描述服务类别
[Service]部分是服务的关键,是服务的一些具体运行参数的设置,这里Type=forking是后台运行的形式,PIDFile为存放PID的文件路径,ExecStart为服务的具体运行命令,ExecReload为重启命令,ExecStop为停止命令,PrivateTmp=True表示给服务分配独立的临时空间,注意:[Service]部分的启动、重启、停止命令全部要求使用绝对路径,使用相对路径则会报错!
[Install]部分是服务安装的相关设置,可设置为多用户的
服务脚本按照上面编写完成后,以754的权限保存在/usr/lib/systemd/system目录下,这时就可以利用systemctl进行配置了
Run systemctl daemon-reload after creating/modifying.
Nginx例子:
vim /usr/lib/systemd/system/nginx.service
[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
在CentOS 7上利用systemctl添加自定义系统服务的更多相关文章
- 在CentOS 7上利用systemctl添加自定义系统服务 /usr/lib/systemd/
在CentOS 7上利用systemctl添加自定义系统服务[日期:2014-07-21] 来源:blog.csdn.net/yuanguozhengjust 作者:yuanguozhengjust ...
- CentOS 7上利用systemctl添加自定义系统服务
Centos 7 之 systemctl CentOS 7继承了RHEL 7的新的特性,例如强大的systemctl,而systemctl的使用也使得以往系统服务的/etc/init.d的启动脚本的方 ...
- CentOS7利用systemctl添加自定义系统服务【转】
systemctl enable name.service 设置开机启 systemctl disable name.service 删除开机启动指令 systemctl list-units --t ...
- 在CentOS 7上利用systemctl加入自己定义系统服务
CentOS 7继承了RHEL 7的新的特性,比如强大的systemctl,而systemctl的使用也使得以往系统服务的/etc/init.d的启动脚本的方式就此改变,也大幅提高了系统服务的执行效率 ...
- [转]CentOS7利用systemctl添加自定义系统服务
原文:https://www.cnblogs.com/saneri/p/7778756.html CentOS7自定义系统服务 CentOS7的服务systemctl脚本存放在:/usr/lib/sy ...
- CentOS7 利用systemctl添加自定义系统服务
一.命令systemctl介绍 CentOS 7.0中已经没有service命令,而是启用了systemctl服务器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起. 命 ...
- CentOS7利用systemctl添加自定义系统服务
CentOS7的每一个服务以.service结尾,一般会分为3部分:[Unit].[Service]和[Install] 转载于互联网 [Unit] 部分主要是对这个服务的说明,内容包括Descrip ...
- systemctl添加自定义系统服务
[Service] Type=forking ExecStart=绝对路径 ExecStop=绝对路径 ExecReload=绝对路径 以上最精简版,文件/usr/lib/systemd/system ...
- CentOS 7 上systemctl 的用法
我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体. systemctl is-enable ...
随机推荐
- [CareerCup] 8.8 Othello Game 黑白棋游戏
8.8 Othello is played as follows: Each Othello piece is white on one side and black on the other. Wh ...
- MyBatis与Hibernate对比
一.相同点 都屏蔽 jdbc api 的底层访问细节,使用我们不用与 jdbc api 打交道,就可以访问数据. jdbc api 编程流程固定,还将 sql 语句与 java 代码混杂在了一起,经常 ...
- iOS使用AVFoundation实现二维码扫描(ios7以上)——转载
关于二维码扫描有不少优秀第三方库: ZBar SDK 里面有详细的文档,相应介绍也非常多,如:http://rdcworld-iphone.blogspot.in/2013/03/how-to-use ...
- 高版本jquery尤其是1.10.2的版本设置input radio设置值的最正确的姿势。
$("input:radio[name="analyshowtype"]").attr("checked",false); $(" ...
- WPF开发时光之痕日记本——终于完工了。。晒晒截图(三)(已上传安装包)
由于是业余时间学习的 WPF 的相关开发且不怎么会使用 Blend 软件,所以开发这个客户端着实花费了我很长时间,比如文本编辑器的开发,最初是在 Simple.HtmlEditor 的基础上做的修改, ...
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
java.lang.IllegalStateException: getWriter() has already been called for this response问题解决 java.lang ...
- User Attributes - Inside Active Directory
User Attributes - Inside Active Directory Related to the book Inside Active Directory, ISBN 0-201-61 ...
- HYSBZ1036 树链剖分
这题我建了2棵线段树,这样来处理 最值和和值,简单的题目. #include<queue> #include<stack> #include<cmath> #inc ...
- jdownload的使用
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- Oracle中的伪列
分页查询中,需要用到伪列rownum,代码如下: select * from (select rownum rn, name from cost where rownum <= 6) where ...