CentOS7设置开机自启动方式
方式一:
# 在/etc/rc.d/rc.local文件中追加启动命令,该文件追加后,会随着机器自动后,自动运行文件中的命令
# vim /etc/rc.d/rc.local # 权限问题:在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限(如遇权限问题,请执行此命令)
# chmod +x /etc/rc.d/rc.local
方式二:
Centos 系统服务脚本目录:
# /usr/lib/systemd/
# /lib/systemd/system/
# 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
# /lib/systemd/system
# 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设置开机自启动方式的更多相关文章
- CentOS7设置开机自启动命令大全
任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.service 使某服务不自 ...
- [CentOS7] 设置开机启动方式(图形界面或命令行)
由于CenOS之前一直都是通过修改inittab文件来修改开机启动模式,于是 通过 vim /etc/inittab 打开inittab来查看 如上所示,CentOS 7由于使用systemd而不是i ...
- CentOS7设置开机启动方式(图形界面/命令行界面)
CentOS 7由于使用systemd而不是init,所以不能通过修改inittab文件来修改开机启动模式. 先使用ctrl+alt+f2切换到命令行模式,然后输入命令:systemctl set-d ...
- redis的安装与设置开机自启动
redis 的安装配置: 可以直接去官网下载((https://redis.io/download) 解压文件到指定目录下 tar zxvf redis-5.0.7.tar.gz -C /opt/ ...
- Fedora 16设置开机自启动程序与Ubuntu的区别
Ubuntu设置开机自启动脚本的方法是:修改/etc/init.d/rc.local这个文件,添加需要启动的程序即可,相关函数如下: void SetSysAutoBoot() { ] = {}; ; ...
- linux_设置开机自启动程序脚本
设置开机自启动
- Linux服务器,服务管理--systemctl命令详解,设置开机自启动
Linux服务器,服务管理--systemctl命令详解,设置开机自启动 syetemclt就是service和chkconfig这两个命令的整合,在CentOS 7就开始被使用了. 摘要: syst ...
- CentOS 6下 Oracle11gR2 设置开机自启动
[1] 更改/etc/oratab # This file is used by ORACLE utilities. It is created by root.sh # and updated by ...
- Ubuntu14.04设置开机自启动脚本
方法一.编辑rc.loacl脚本 Ubuntu开机之后会执行/etc/rc.local文件中的脚本,所以我们可以直接在/etc/rc.local中添加启动脚本.在 exit 0 前面添加好脚本代码, ...
随机推荐
- U盘的几种分类及格式
u盘常见的几种分类: 1.按u盘材质来分,可以分为金属u盘.塑料u盘.软胶u盘.皮革u盘.木质u盘.珠宝u盘等.这些主要是考虑u盘本身外壳所用材质的. 2.从u盘容量来分,就是8GB.16GB.32G ...
- Scrapy中的Request和日志分析
Scrapy.http.Request 自动去重,根据url的哈希值,进行去重 属性 meta(dict) 在不同的请求之间传递数据,dict priority(int) 此请求的优先级(默认为0 ...
- Ubuntu下doxygen+graphviz使用概录
关键词:doxygen.Doxyfile.doxywizard.dot.graphviz等等. 使用doxygen从源码注释生成帮助文档或者SDK,输出格式有多种比如htmp.Latex等等. 如果想 ...
- 不相交集ADT 你是和谁是一类人?
//不相交集ADT (抽象数据类型) //一般用于集合运算 //用树,这种结构组成,有多个树(=森林) //属于同一颗数的元素,表示处于同一个集合中 //主要支持2个操作. //1. Find操作,找 ...
- eclipse拉取git项目 Read timed out after 30,000 ms
点击 eclipse -> Window -> Preferences -> Team ->git 在git选项里有Remote connection timeout ,默 ...
- 在Windows系统中安装matplotlib,需要注意的问题
matplotlib的下载地址:https://pypi.org/project/matplotlib/#files 以python3.6为例,适合的版本matplotlib-3.1.1-cp36-c ...
- 【CodeForces】CodeForcesRound594 Div1 解题报告
点此进入比赛 \(A\):Ivan the Fool and the Probability Theory(点此看题面) 大致题意: 给一个\(n\times m\)的矩阵\(01\)染色,使得不存在 ...
- Codeforces Round #598 (Div. 3) B. Minimize the Permutation 贪心
B. Minimize the Permutation You are given a permutation of length n. Recall that the permutation is ...
- golang数据结构之递归解决迷宫问题
简单来说:递归就是函数/方法自己调用自己,只是每次传入不同的变量. 递归可以解决各种数学问题:n皇后问题.阶乘问题.汉诺塔.迷宫问题.球和篮子问题等等: maze.go package maze im ...
- golang--海量用户即使通讯系统
功能需求: 用户注册 用户登录 显示在线用户列表 群聊 点对点聊天 离线留言