#!/bin/bash BIN_PROC_FILES="my_bin" LOG_FILE=/tmp/memlog.log RM_LOG_FILE=0 G_STDOUTPUT=1 function write_log { CUR_TIME_STR=`date +"%Y%m%d_%H%M%S"` if [ ${G_STDOUTPUT} -gt 0 ]; then echo "${CUR_TIME_STR} $1" fi if [ "${LOG_FILE}" != "" ] ; then echo "${CUR_TIME_STR} $1" >> ${LOG_FILE} fi } function loop_proc { for CUR_BIN in ${BIN_PROC_FILES} do PID_SNIPER=`pidof ${CUR_BIN}` if [ "${PID_SNIPER}" != "" ]; then MEM_STATS=`ps --pid ${PID_SNIPER} -o rss,vsz` LINE_CNT=`echo "${MEM_STATS}" | wc -l` if [ ${LINE_CNT} -gt 1 ]; then MEM_STAT=`echo "${MEM_STATS}" |tail -n 1` fi write_log "${CUR_BIN} ${PID_SNIPER} ${MEM_STAT}" fi done } if [ ${RM_LOG_FILE} -gt 0 ]; then if [ "${LOG_FILE}" != "" ] ; ...