#!/usr/bin/bash # Nice monitor — ensures claude processes run at lowest CPU priority. # Checks every 30 seconds and renices any claude process not already at nice 19. # Kill other instances of this script for pid in $(pgrep -f 'nice-monitor.sh' | grep -v $$); do kill "$pid" 2>/dev/null done while true; do for pid in $(pgrep -f 'claude' 2>/dev/null); do cur=$(awk '{print $19}' /proc/$pid/stat 2>/dev/null) if [ -n "$cur" ] && [ "$cur" != "19" ]; then renice 19 -p "$pid" > /dev/null 2>&1 fi done sleep 30 done