Here’s how to run a script on bootup on Rhel 7 that’s running systemd.

First create a script. It this case, it will create a file called test.txt.

<pre lang="bash">
> /root/test.txt

Make the script executable.

<pre lang="bash">
chmod /root/

Now create a service in /etc/systemd/system/test.service

<pre lang="bash">
# vi /etc/systemd/system/test.service
Description=A test service

Reload systemd.

<pre lang="bash">
systemctl daemon-reload

Enable the service.

<pre lang="bash">
systemctl enable test.service

Start the service.

<pre lang="bash">
systemctl start test.service

Reboot and test.

<pre lang="bash">

Validate if the script ran. Check if the file was created.