I am running a CentOS (Red Hat Enterprise Linux Server release 7.6 (Maipo)) instance on AWS. I need to add to my boot sequence execution of a rc.local script.

How can I do that? I have looked in /ect/rc.d and tried to add the script to a default using systemctl. Nothing works.

Can someone point me to a right direction?

  • Which CentOS version is it?
    – Itai Ganot
    Apr 23, 2019 at 10:11
  • 1
    Without knowing much about CentOS I use /etc/init.d/boot.local on a openSUSE virtual machine, that works for me.
    – eblock
    Apr 23, 2019 at 10:11
  • 2
    For several CentOS versions you should forget about rc.local.
    – JdeBP
    Apr 23, 2019 at 10:50

1 Answer 1


There are at least three methods you can use as far as I see it.

  1. Using /etc/rc.d/rc.local:

Make sure the file is executable or chmod u+x it.

Add the commands / script to the end of the file.

  1. Using crontab:


crontab -e

Then add a crontab line like so:

@reboot /your/script/here
  1. a Userdata script:

Since it's an AWS instance, you can create a shell script, upload it to s3 and configure the instance to download and run it at instance creation time.

Here's an example of a userdata script I wrote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.