#!/bin/bash self_pid=$$ echo $self_pid count=`ps axu |grep -E ${1}|grep -E ${0} |grep -v grep |grep -v ${self_pid}|wc -l` echo $count if [ $count -ne 1 ] then echo $(ps aux|grep -E ${1}|grep -E ${0}|grep -v grep|grep -v ${self_pid}) ps axu |grep -E $1 |grep -E $0 |grep -v grep |grep -v $self_pid |awk '{print $2}'|xargs kill -9 fi res=record_$1_res.csv virt=record_$1_virt.csv echo $res echo $virt >$res >$virt for ((;;)) do top -n 1 b|grep $1|grep -v logfork |awk '{print $5}'|sed 's#[a-z]##g' >>$virt top -n 1 b|grep $1|grep -v logfork |awk '{print $6}'|sed 's#[a-z]##g' >>$res sleep 3 done
sh record.sh binbash