awk '{print $20}' /proc/pid_num/stat
or
$ /proc/pid_num/status has a Threadsor
#!/bin/bash
if [ -z $1 ];then
echo "enter an exectue name in background, ex: chrome"
exit
fi
target=$(ps -ef | grep -v grep | grep $1 | awk '{print $2}')
for pid in $target
do
if [ -d /proc/$pid ]; then
echo pid=$pid, `awk '{print $20}' /proc/$pid/stat`
fi
done
$1: PID, Process PID1. /proc/stat解析
沒有留言:
張貼留言