在 CentOS7 中,在/etc/rc.local 脚本文件中编写启动程序的脚本,可以实现开机启动程序。
1、/etc/rc.local 是/etc/rc.d/rc.local 的软链接
执行 ls -l /etc/rc.local 看看。
/etc/rc.local 是/etc/rc.d/rc.local 文件的软链接,也就是说他们是同一个文件。
2、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
中文意思如下:
# 添加此文件是为了兼容。
# 强烈建议创建自己的 systemd 服务或 udev 规则,以便在引导期间运行脚本,而不是使用此文件。
# 与以前版本不同,由于在引导期间并行执行,此脚本不会在所有其他服务之后运行。
# 请注意,必须运行'chmod +x /etc/rc.d/rc.local',以确保在引导期间执行此脚本。
明白了吧。