CentOS7设置自定义开机启动,添加自定义系统服务
Centos 系统服务脚本目录:
/usr/lib/systemd/
有系统(system)和用户(user)之分,如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即:
lib/systemd/system/
反之,用户登录后才能运行的程序,存在用户(user)里,服务以.service结尾。
这边以nginx开机运行为例:
1.建立服务文件
vim /lib/systemd/system/nginx.service
[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/www/lanmps/init.d/nginx start ExecReload=/www/lanmps/init.d/nginx restart ExecStop=/www/lanmps/init.d/nginx stop PrivateTmp=true [Install] WantedBy=multi-user.target
[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]服务安装的相关设置,可设置为多用户
2.保存目录
以754的权限保存在目录:
/lib/systemd/system
3.设置开机自启动
systemctl enable nginx.service
4.其他命令
|
任务 |
旧指令 |
新指令 |
|
使某服务自动启动 |
Chkconfig --level 3 httpd on |
systemctl enable httpd.service |
|
使某服务不自动启动 |
chkconfig --level 3 httpd off |
systemctl disable httpd.service |
|
检查服务状态 |
service httpd status |
systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service(仅显示是否Active) |
|
显示所有已启动的服务 |
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 |
启动nginx服务:
systemctl start nginx.service
设置开机自启动:
systemctl enable nginx.service
停止开机自启动:
systemctl disable nginx.service
查看服务当前状态:
systemctl status nginx.service
重新启动服务:
systemctl restart nginx.service
查看所有已启动的服务:
systemctl list-units --type=service
CentOS7设置自定义开机启动,添加自定义系统服务的更多相关文章
- CentOS 7 设置自定义开机启动,添加自定义系统服务
详细文档,http://www.linuxidc.com/Linux/2015-04/115937.htm 摘自: http://www.centoscn.com/CentOS/config/2015 ...
- CentOS 7.x设置自定义开机启动,添加自定义系统服务
Centos 系统服务脚本目录: /usr/lib/systemd/ 有系统(system)和用户(user)之分, 如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即: /l ...
- (转)Mysql数据库之Binlog日志使用总结CentOS 7.x设置自定义开机启动,添加自定义系统服务
Centos 系统服务脚本目录: /usr/lib/systemd/ 有系统(system)和用户(user)之分, 如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即: li ...
- Centos7 设置Mongodb开机启动-自定义服务
(1).在/lib/systemd/system/目录下新建mongodb.service文件,内容如下 [Unit] Description=mongodb After=network.target ...
- centos7 设置 查看 开机 启动项
1.查看开机自启项centos7自启项已不用chkconfig改为:systemctl list-unit-files左边是服务名称,右边是状态,enabled是开机启动,disabled是开机不启动 ...
- linux centOS7 设置 redis 开机启动
1.为了让redis-server能在系统启动时自动运行,需要将redis服务作为守护进程(daemon)来运行,我们回/usr/local/cluster/7000/目录中找到一个redis.con ...
- systemd添加自定义系统服务设置自定义开机启动
1.服务权限 systemd有系统和用户区分:系统(/user/lib/systemd/system/).用户(/etc/lib/systemd/user/).一般系统管理员手工创建的单元文件建议存放 ...
- linux(centos7)设置tomcat开机启动
1.在/etc/rc.d/rc.local中加入: #java environment export JAVA_HOME=/usr/java/jdk1.8.0_161 export CLASSPATH ...
- linux开机自启动设置,自定义开机启动模版,nginx开机自启动服务
/etc/init.d 目录,我们把shell脚本放在这个目录下来作为启动脚本 都是用来放服务脚本的,当Linux启动时,会寻找这些目录中的服务脚本,并根据脚本的run level确定不同的启动级别. ...
随机推荐
- CPC广告反作弊
原文:http://blog.csdn.net/xwm1000/article/details/45460957 CPC广告上线也2年了,从上线以来就一直存在着作弊和反作弊的斗争,刚开始的时候流量少, ...
- 如何在程序中使用CString
在新建项目的时候,如果选择了MFC并且使用ATL,那么在程序中使用CString是没有问题的. 但是如果当初没有选,后面再改,虽然选上了,但是CString在编译的时候还是不被编译器识别.怎么办那? ...
- PHPCMS增加投票选项代码
<script src="jquery-1.10.1.js"></script> <tr> <th width="20%&quo ...
- 《Java程序设计》第16周周四:GUI编程及文件对话框的使用
第一部分:实验项目 项目一:文件及选择 目的:了解文件对话框的用法,熟悉GUI中事件驱动的核心步骤. 1. 阅读博文 "JFileChooser (Java Swing提供的文件选择对话框 ...
- .net反编译工具ILSpy
下载地址:http://www.fishlee.net/service/softarchive/57
- 跨站点脚本编制-XSS 描述及解决方法
跨站点脚本编制可能是一个危险的安全性问题,在设计安全的基于 Web 的应用程序时应该考虑这一点.本文中,描述了这种问题的本质.它是如何起作用的,并概述了一些推荐的修正策略. 当今的大多数网站都对 We ...
- PHPstorm最常用的快捷键,提高开发效率
PHPstorm最常用的快捷键,提高开发效率 •ctrl+b 跳到变量申明处 •Ctrl + E 打开最近文件 •Ctrl + R 替换. •Ctrl + D 复制粘贴.将当前行或者选择的内容复制粘贴 ...
- 解决ios微信内置浏览器触发事件有问题方案
你的问题原因是事件冒泡导致找不到或者找到多个事件导致的, 你这样去写! $(“#div1").on("click",".k1",function(){ ...
- SettingsEclipse&MyEclipse
eclipse优化 迁移时间--2017年5月20日09:39:16 CreateTime--2016年11月18日11:27:02 Author:Marydon ModifyTime--2017 ...
- php 5.3 垃圾回收
1.引用计数器 php中的每个变量都存在一个zval的变量容器中, zval容易包括变量类型.值.is_ref(是否是引用).refercount(引用次数,也成为符号), 所有的符号存在一个符号表中 ...