Skip to content

Instantly share code, notes, and snippets.

@neingeist
Created March 15, 2017 19:59
Show Gist options
  • Save neingeist/196dce933f2edbc475a35f2ab03d296e to your computer and use it in GitHub Desktop.
Save neingeist/196dce933f2edbc475a35f2ab03d296e to your computer and use it in GitHub Desktop.
reboot-if-required
#!/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'])
@CODINGIINGISTHEBEST
Copy link

Nice

@neingeist
Copy link
Author

neingeist commented Jun 10, 2020

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