Created
March 15, 2017 19:59
-
-
Save neingeist/196dce933f2edbc475a35f2ab03d296e to your computer and use it in GitHub Desktop.
reboot-if-required
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
| #!/usr/bin/python | |
| from __future__ import print_function | |
| import os | |
| import random | |
| import subprocess | |
| import time | |
| if os.path.exists('/var/run/reboot-required'): | |
| sleep = random.randint(60, 1800) | |
| print('Reboot required, sleeping for {} seconds before rebooting'.format(sleep)) | |
| time.sleep(sleep) | |
| subprocess.call(['/sbin/reboot']) |
Author
i should not that this only works for debian and ubuntu, as a kernel install leaves the file /var/run/reboot-required there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice