Retrieve CPU usage and memory usage of a single process on Linux?

前端 未结 21 1945
抹茶落季
抹茶落季 2020-11-27 09:00

I want to get the CPU and memory usage of a single process on Linux - I know the PID. Hopefully, I can get it every second and write it to a CSV using the \'watch\' command

21条回答
  •  暖寄归人
    2020-11-27 09:54

    ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr
    

    or per process

    ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr |grep mysql
    

提交回复
热议问题