-
Notifications
You must be signed in to change notification settings - Fork 1
Use cron to revert changes
anderpups edited this page Oct 17, 2023
·
3 revisions
You can use cron to revert changes that could possibly break the network.
This is useful for hosts that you don't have physical access to.
-
Login to the host via ssh.
-
Make a copy of the file you are about to change
sudo cp /etc/systemd/network/04-eth0.network /etc/systemd/network/04-eth0.network.old
-
Create a cronjob at minute 0 and minute 30 of every hour that will revert the file and reboot. Adjust the times as needed. You can remove the reboot command to make sure the file will actually be reverted prior to making any permanent changes. Type
sudo crontabe -eto open root's crontab. Enter the following:# Revert changes 0,30 * * * * /usr/bin/cp /etc/systemd/network/04-eth0.network.old /etc/systemd/network/04-eth0.network; sudo reboot
-
Make your changes and restart networking or reboot. If your changes break networking,the cronjob will run, revert the changes and reboot the system. If your change is successful, remove the cronjob