RHEL 7 and CentOS 7 moved to systemd from System V init facility. So if we want to run a script at boot, it is highly recommended that you should write a systemd unit file. However to ease the transition to systemd, CentOS7 /RHEL7 offers a backward compatibility mode for init scripts.
In a System V init system you need to add an entry of the script to /etc/rc.local (or equivalent) and the script will be executed during boot at the end of multi user run level.
In CentOS7 /etc/rc.local is a symbolic link to /etc/rc.d/rc.local.
root@localhost ~]# ls -l /etc/rc.local lrwxrwxrwx. 1 root root 13 Apr 4 2016 /etc/rc.local -> rc.d/rc.local
To enable the init compatibility mode, you need to make /etc/rc.d/rc.local executable and then add the script to /etc/rc.local.
Here are the steps you need to perform to to start a script e.g. hello.sh during boot.
$ chmod +x /etc/rc.d/rc.local #make the script executable $ chmod +x hello.sh #Make a entry in /etc/rc.local $ 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 /root/hello.sh
Reference : https://www.centos.org/forums/viewtopic.php?t=48140