Centos7 run shell during boot

to run scripts during boot

Posted by Dongyupu on October 10, 2017

Setup 1
touch your_shell.sh

  #!/bin/bash
  ./review-site/bin/gerrit.sh restart
  service nginx restart

Setup 2

  add executed permission
  chmod +x path_to_your_shell.sh

Setip 3

  edit /etc/rc.d/rc.local ,add shell to run 
  eg:/home/gerrit/start_gerrit_nginx.sh

Setp 4

Read /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

  Centos 7
  #!/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.
  Centos 6.5
  #!/bin/sh
  #
  # This script will be executed *after* all the other init scripts.
  # You can put your own initialization stuff in here if you don't
  # want to do the full Sys V style init stuff.

End reboot system