linux usage cpu code example
Example 1: linux check cpu usage
lscpu
# Or
cat /proc/cpuinfo
Example 2: log cpu usage on linux
while true; do (echo "%CPU %MEM ARGS $(date)" && ps -e -o pcpu,pmem,args --sort=pcpu | cut -d" " -f1-5 | tail) >> ps.log; sleep 5; done