spaceforge / scripts /cleanup_ttl.py
2Btainment's picture
Upload folder using huggingface_hub
3806142 verified
Raw History Blame Contribute Delete
531 Bytes
#!/usr/bin/env python3
"""Optional cron helper: purge expired build dirs."""
from __future__ import annotations
import shutil
import time
from pathlib import Path
TTL = 3600
ROOT = Path("/data/builds") if Path("/data/builds").exists() else Path("/tmp/spaceforge/builds")
def main() -> None:
if not ROOT.exists():
return
now = time.time()
for d in ROOT.iterdir():
if d.is_dir() and now - d.stat().st_mtime > TTL:
shutil.rmtree(d, ignore_errors=True)
if __name__ == "__main__":
main()