Shell ps command under Ubuntu -
i have question regarding shell scripts. trying specific possible. so, have write monitoring shell script in have write in file users running vi command more, 1 minute. don't have idea approach, except should use ps command. have this:
ps -ewo "%t %u %c %g" | grep '\< vi >'
with times , users run vi command. problem don't know how parse result of command. can help, please? answers appreciated. thanks
i use awk:
ps eo user,etime,pid,args --no-heading -c vi | awk '{min=int(substr($2,0,2)); printf "minutes=%s pid=%d\n", min, $3; }' note, dont have grep "vi", can use "ps -c procname".
Comments
Post a Comment