#! /bin/bash ### autoexec service httpd restart #################################################### # do auto exec service httpd restart in current node # see https://linuxconfig.org/how-to-automatically-execute-shell-script-at-startup-boot-on-systemd-linux for How to automatically execute shell script at startup boot on systemd Linux # execute as su ## create /etc/systemd/system/httpd-restart.sh echo '#!/bin/bash' > /usr/local/bin/httpd-restart.sh echo 'service httpd restart' >> /usr/local/bin/httpd-restart.sh chmod 744 /usr/local/bin/httpd-restart.sh ## create /etc/systemd/system/service-httpd-restart.service cat << EOF > /etc/systemd/system/service-httpd-restart.service [Unit] After=mysql.service [Service] ExecStart=/usr/local/bin/httpd-restart.sh [Install] WantedBy=default.target EOF # Next, install systemd service unit and enable it so it will be executed at the boot time: chmod 664 /etc/systemd/system/service-httpd-restart.service systemctl daemon-reload systemctl enable service-httpd-restart.service