Files
agnos-builder/userspace/root/usr/comma/varwatch.py
T
2026-04-30 18:15:09 -07:00

17 lines
473 B
Python
Executable File

#!/usr/bin/env python3
import os
import time
if __name__ == "__main__":
# we are the last line of defense for /var/log filling up
while True:
usage = os.statvfs('/var/log')
percent = (usage.f_blocks - usage.f_bavail) / usage.f_blocks * 100
if percent > 70:
for fn in os.listdir('/var/log'):
file_path = os.path.join('/var/log', fn)
if os.path.isfile(file_path):
with open(file_path, 'w'):
pass
time.sleep(1)