#!/bin/sh # Kill viewvc if the process gets too large max_memory=1000000 # size in KiB for process in $(pgrep viewvc.fcgi) do process_mem=$(pmap "$process" | grep total | sed 's/ \+total \+\([[:digit:]]\+\)K/\1/') if [ -n "$process_mem" ] && [ "$process_mem" -gt "$max_memory" ] then kill -15 "$process" fi done