I want to run a custom bash script before httpd service is started with systemd. I'm using Centos 7.
Any idea?
Kind regards.
We can use systemd unit files to launch our script at boot. Unit files describe how the system should execute the given program. We set the user that the script will run with the User= option and the path to the script with the ExecStart= option. The various options are documented in the systemd.
Assuming your httpd service is named httpd.service
, create a directory /etc/systemd/system/httpd.service.d
; and create a file named run-my-script-first.conf
(or whatever you like) within it with the following contents:
[Service]
ExecStartPre=/path/to/your/script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With