0

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?

1 Answers1

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:

Run:

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.