#! /bin/bash # 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/network-service-restart.sh echo '#!/bin/bash' > /usr/local/bin/network-service-restart.sh echo 'service NetworkManager restart' >> /usr/local/bin/network-service-restart.sh echo 'service network restart' >> /usr/local/bin/network-service-restart.sh chmod 744 /usr/local/bin/network-service-restart.sh ## create /etc/systemd/system/service-network-restart.service cat << EOF > /etc/systemd/system/service-network-restart.service [Unit] After=mysql.service [Service] ExecStart=/usr/local/bin/network-service-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-network-restart.service systemctl daemon-reload systemctl enable service-network-restart.service # If you wish to test your script before you reboot run: systemctl start service-network-restart.service