Skip to content
Advertisement

How to run commands on CentOS reboot

I want to run the following commands one after the other upon reboot of the server after I do shutdown -r now but not sure how to do it:

  • getenforce

  • setenforce 0

  • systemctl start httpd.service

I’m running CentOS 7.x

Advertisement

Answer

Technically you can crontab it

JavaScript

and add the line

JavaScript

and put the 3 commands in the myscript.sh with the proper rights.

But it is a bad idea since you can you just make these changes permanent:

JavaScript

and

JavaScript

to set the SELINUX variable to permissive

This will make the configuration permanent across reboot.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement