# yum -y install ps_mem
# yum info ps_mem
关于proc目录下进程的cwd信息
/proc/$pid/cwd
The process.cwd() method returns the current working directory of the process.
process.cwd()返回的是当前进程执行时的工作目录就是说process.cwd()返回的是当前进程执行时的工作目录.
# cat list_mem-cpu.sh
#@@@@@@@@@@@@@@@@@@@@#
#!/bin/bash
mem_pids=`ps -aux | sort -k4nr | head -n 5 | awk '{print $2}'`
cpu_pids=`ps -aux | sort -k3nr | head -n 5 | awk '{print $2}'`
echo "#####################"
echo "内存占用前5的进程"
for mem_pid in ${mem_pids}
do
ls -lt /proc/${mem_pid}/cwd
ps_mem -p ${mem_pid}
done
echo "#######################"
echo "CPU占用前5的进程"
for cpu_pid in ${cpu_pids}
do
ls -lt /proc/${cpu_pid}/cwd
done
#@@@@@@@@@@@@@@@@@@@@#
网友评论