Skip to content

Instantly share code, notes, and snippets.

@guilhermegazzinelli
Last active February 14, 2023 12:39
Show Gist options
  • Save guilhermegazzinelli/c2af67828e60abe9c9673987115a97db to your computer and use it in GitHub Desktop.
Save guilhermegazzinelli/c2af67828e60abe9c9673987115a97db to your computer and use it in GitHub Desktop.
Reboot linux if Needed
#!/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
@guilhermegazzinelli
Copy link
Author

This gist verify if file /var/run/reboot-required is present, since it represents if the server needs restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment