这里假定要获取当前登录用户启动的tomcat进程的cpu使用情况
#!/bin/sh _USER=`whoami` _PS=`ps -ef | grep $_USER | grep catalina | grep tomcat` _PID=`echo $_PS | awk '{print $2}'` _CPUINFO=`top -b -n 1 -p $_PID | sed '$d' | sed -n '$p' | awk '{print $9}'` echo $_CPUINFO
这里假定要获取当前登录用户启动的tomcat进程的cpu使用情况
#!/bin/sh _USER=`whoami` _PS=`ps -ef | grep $_USER | grep catalina | grep tomcat` _PID=`echo $_PS | awk '{print $2}'` _CPUINFO=`top -b -n 1 -p $_PID | sed '$d' | sed -n '$p' | awk '{print $9}'` echo $_CPUINFO