#!/bin/bash
# stops any local lean4lean whose memory passes 70 GB
while :; do for p in $(pgrep -x lean4lean); do r=$(awk '/^VmRSS/{print $2}' /proc/$p/status 2>/dev/null); if [ -n "$r" ] && [ "$r" -gt 70000000 ]; then echo "$(date -u +%FT%TZ) lean4lean pid $p at $r kB: stopped to protect this machine" >> /home/claude/grh/short/logs/memory-guard.log; kill $p; fi; done; sleep 10; done
