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 前面添加好脚本代码, ...
随机推荐
- How To Restore Rman Backups On A Different Node When The Directory Structures Are Different (Doc ID 419137.1)
How To Restore Rman Backups On A Different Node When The Directory Structures Are Different (Doc ID ...
- git 现在本地创建仓库 再 推送到 远程 github 仓库中
今天,需要再本地使用git管理代码,但是当代码创建好的时候,想发布到github上面的私有仓库中,但是没有提前创建远端仓库,所以需要把本地git仓库推送到远端另外一个仓库了,下面进行简要记录,刚刚经过 ...
- PyCharm将选中的内容加上引号
正常情况下,选中一段内容,再按引号,内容会被替换为引号 想要将选中的内容不被替换为引号,而在内容的两端加上引号,只需设置一下即可 File --> Settings --> Edi ...
- Mybatis整合Redis实现二级缓存
Mybatis集成ehcache . 为什么需要缓存 拉高程序的性能 . 什么样的数据需要缓存 很少被修改或根本不改的数据 业务场景比如:耗时较高的统计分析sql.电话账单查询sql等 . ehcac ...
- Repair Microsoft.VisualStudio.MinShell.Msi.Resources 2203 error And visual studio 2019 key
1. Go to the properties of "My computer" 2. Go to advanced settings of the system 3. Go to ...
- 通过windows组策略配置时间同步
Windows系统中带有NTP服务器和客户端的程序,只需在Windows中简单配置即可实现电脑之间的时间同步. 网上常见的配置NTP服务器的方法是修改系统注册表,这种方法是微软不推荐的.在实际使用中, ...
- 完美解决MacOS catalina 升级后Vmware黑屏的问题
完美解决MacOS catalina 升级后VMware黑屏 1.关闭MacOS的rootless机制 #Rootless机制将成为对抗恶意程序的最后防线 1.尝试关闭Rootless,重启按住 Co ...
- DirectShow 常用函数总结
本文准备总结一些 Direct Show 常用的API接口函数,方便以后查询回忆.如果这里没有你想了解的函数,你可以自行搜索MSDN + 函数名去 MSDN 查找你想要了解的函数,也可以查看百度百科相 ...
- HTML连载41-水平居中的注意点、盒子居中和内容居中
一.盒子模型练习 我们有个需求: 创建两个盒子,大盒子嵌套一个小盒子,大盒子是红色的,小盒子是蓝色的,并且小盒子在大盒子中是居中的. <!DOCTYPE html> <html la ...
- 大话设计模式Python实现-组合模式
组合模式(Composite Pattern):将对象组合成成树形结构以表示“部分-整体”的层次结构,组合模式使得用户对单个对象和组合对象的使用具有一致性. 下面是一个组合模式的demo: #!/us ...