Last active
February 14, 2023 12:39
-
-
Save guilhermegazzinelli/c2af67828e60abe9c9673987115a97db to your computer and use it in GitHub Desktop.
Reboot linux if Needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -eq 0 ]] ; then | |
echo 'Must pass an time for reboot in form hh:mm' | |
exit 1 | |
fi | |
if [ -f /var/run/reboot-required ]; then | |
echo 'Reboot required, scheduling based on parameter' | |
sudo shutdown -r $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist verify if file
/var/run/reboot-required
is present, since it represents if the server needs restart.