Mille grazie a tutti quanti; se qualcuno fosse interessato posto lo script:
#!/bin/bash pname=dar logger=$(which logger) [ -z $logger ] && echo "E: logger not found" && exit 1 logger="$logger -t $(basename $0 .sh)" while [ 1 = 1 ]; do pid=$(pidof $pname | cut -f1 -d\ ) maxram=0 if [ -n "$pid" ]; then $logger "I find a process with name $pname (pid $pid): I begin to monitor the max RAM used by the process" while [ "$(pidof $pname)" = "$pid" ]; do str="[[:space:]]*[^[:space:]]*" cmd="ps aux -p $pid | tail -n1 | sed 's/^" for i in {1..4}; do cmd=$cmd$str; done # I skip first 4 (USER,PID,%CPU,%MEM,VSZ) cmd="$cmd[[:space:]]*\([^[:space:]]*\).*$/\1/'" curram=$(eval $cmd) # echo "$(date --rfc-3339=seconds) ($pid): $curram" if [ -z "$(echo $curram | grep ^[0-9]*$)" ]; then $logger "E: error finding the RAM amount used by $pname: $curram doesn't seems to be numeric" elif [ $curram -gt $maxram ]; then maxram=$curram fi sleep 1 done $logger "the process $pname ($pid) has used $maxram Kib" fi sleep 10 done