centos7下的/etc/rc.local自启动程序

在centos6中有一个/etc/rc.local的启动文件,只要把需要经常启动的程序添加到此文件下并执行source /etc/rc.local就可以实现开机启动了。
在centos7中不知道也是如此操作吗?

    [[email protected] ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure ,看到这句话,就会发现需要给文件/etc/rc.local添加执行权限就可以实现程序自启动。

原文地址:https://www.cnblogs.com/wang50902/p/11702734.html

时间: 2024-08-29 14:39:34

centos7下的/etc/rc.local自启动程序的相关文章

rc.local自启动学习

linux有自己一套完整的启动体系,抓住了linux启动的脉络,linux的启动过程将不再神秘. 本文中假设inittab中设置的init tree为: /etc/rc.d/rc0.d /etc/rc.d/rc1.d /etc/rc.d/rc2.d /etc/rc.d/rc3.d /etc/rc.d/rc4.d /etc/rc.d/rc5.d /etc/rc.d/rc6.d /etc/rc.d/init.d 目录 1. 关于linux的启动 2. 关于rc.d 3. 启动脚本示例 4. 关于rc

rc.local自启动学习(转)

linux有自己一套完整的启动体系,抓住了linux启动的脉络,linux的启动过程将不再神秘. 本文中假设inittab中设置的init tree为: /etc/rc.d/rc0.d/etc/rc.d/rc1.d/etc/rc.d/rc2.d/etc/rc.d/rc3.d/etc/rc.d/rc4.d/etc/rc.d/rc5.d/etc/rc.d/rc6.d/etc/rc.d/init.d 目录 1. 关于linux的启动2. 关于rc.d3. 启动脚本示例4. 关于rc.local5. 关

Linux的rc local自启动服务

linux有自己一套完整的启动体系,抓住了linux启动的脉络,linux的启动过程将不再神秘. 本文中假设inittab中设置的init tree为: /etc/rc.d/rc0.d/etc/rc.d/rc1.d/etc/rc.d/rc2.d/etc/rc.d/rc3.d/etc/rc.d/rc4.d/etc/rc.d/rc5.d/etc/rc.d/rc6.d/etc/rc.d/init.d 目录 1. 关于linux的启动2. 关于rc.d3. 启动脚本示例4. 关于rc.local5. 关

CentOS 6.5 rc.local 开机不执行的原因之一

好久不动Linux,最近帮朋友弄了一下. 新买的阿里云主机,由于内存1GB所以选择了32bit的CentOS6.5. 安装软件和配置及其一些优化都很顺利,可是希望能在开机启动的时候启动web服务器和数据库,我的习惯做法是把启动脚本放在rc.local里面.重启发现根本没生效,测试了一下写法上没有任何问题.但是又找不到问题在哪里,Google了一下没找到什么有用的信息,偶然发现有人在写权限的问题,他写的是即使给了rc.local执行权限仍然无法执行,我看看下是他的脚本写错了.反过来我看了下我的rc

centos7下/etc/rc.local文件里配置的开机启动项不执行的解决办法

习惯于在/etc/rc.local文件里配置我们需要开机启动的服务,这个在centos6系统下是正常生效的.但是到了centos7系统下,发现/etc/rc.local文件里的开机启动项不执行了!仔细研究/etc/rc.local文件内容,发现问题如下: [[email protected] ~]# cat /etc/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advi

Linux开机启动程序rc.local

目录 1./etc/rc.local是/etc/rc.d/rc.local的软链接 2.rc.local文件的原始内容 3.rc.local文件的配置 4.应用经验 5.版权声明 在CentOS7中,实现开机启动程序主要有两种方法: 1)把要启动的程序配置成自定义的系统服务,该方法我已经介绍过,请阅读:CentOS7添加自定义系统服务. 2)在/etc/rc.local脚本文件中编写启动程序的脚本,本文将详细介绍这种方法. 1./etc/rc.local是/etc/rc.d/rc.local的软

CentOS7 rc.local开机开法启动

CentOS 7添加开机启动服务/脚本 一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例):systemctl enable jenkins.service #设置jenkins服务为自启动服务sysstemctl start  jenkins.service #启动jenkins服务 二.添加开机自启脚本 在centos7中增加脚本有两种常用的方法,以脚本autostart.sh为例:#!/bin/bash#description:开机自

用rc.local工具开机自启动

对于一些程序来说,无法直接开机自启动.那么我们可以利用开机自启动来执行一些命令,达到开机自启动的效果!!! 下面用tomcat来举个例子 tomcat启动的命令一般是./startup.sh 那么我们就把他的命令放到rc.local目录下,来达到开机自启动的效果!! 首先得给rc.local的执行的权限!! chmod +x /etc/rc.d/rc.local 然后把想让系统开机执行的命令放到文件里就可以了!! 原文地址:https://www.cnblogs.com/yeyu1314/p/1

centos7 开机/etc/rc.local 不执行的问题

centos7 开机/etc/rc.local 不执行的问题 背景: 最近客户那边新上一台server,系统是Centos7, 我写个开机执行脚本. 发现的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了 #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd service