Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 netstat 查找进程 ID,并使用 ps 查看该进程运行了多长时间。我目前有两个单独的命令来执行此操作。我如何用一个命令来做到这一点?
netstat -anp | grep http | grep ESTABLISHED | awk {'print $7}' | awk -F '/' {'print $1'}
和:
ps -eo pid,uid,ruser,etime | grep someuser
for i in `netstat -anp | grep http | grep ESTABLISHED | awk {'print $7}' | awk -F '/' {'print $1'} | uniq` ; do ps -eo pid,uid,ruser,etime | grep $i ; done