#ps
10 one-liners with this tag.
All one-liners tagged ps
Count processes per user
$ps -eo user= | sort | uniq -c | sort -rn
Count running Apache processes
$ps -C apache2 --no-headers | wc -l
Find zombie processes and their parent processes
$ps -eo pid,ppid,stat,cmd | awk 'NR == 1 || $3 ~ /^Z/'
Show currently running cron jobs
$ps -eo pid,user,etime,cmd --forest | grep -A3 '[C]RON'
Show processes as a tree with parents and children
$ps -ef --forest
Show processes with the highest CPU usage
$ps aux --sort=-%cpu | head -15
Show processes with the highest RAM usage
$ps -eo pid,user,%mem,rss,cmd --sort=-rss | head -15
Show running lsphp processes with memory usage
$ps -eo pid,user,%cpu,rss,etime,cmd --sort=-rss | grep -E "[l]sphp"
Show start time and runtime of a process
$ps -o pid,user,lstart,etime,cmd -p 1234
Sum up RAM usage per program
$ps -eo rss=,comm= | awk '{a[$2]+=$1} END {for (p in a) printf "%8.1f MB %s\n", a[p]/1024, p}' | sort -rn | head -15