Search code examples
linuxshellstartup

How to run a shell script at startup for Red Hat 7.3


I want to run a script when my RHEL 7.3 machine boots up. The script restarts docker service and restarts my container.

The script:

#!/bin/bash
sudo service docker start
sleep 10s
docker restart Free

How do I get this script to run every time my Red Hat machine is powered on.


Solution

  • One of the easiest way to add you script into the file /etc/rc.local