Linux - Ps command monitoring top memory and process, Find which process use more system resource
Ps command monitoring top memory and process
The below commands can be used to calculate system resource used by server. You can find which commandline is using more CPU resource. But ofcourse you can calculate the system resource by using top command, but still below are the below commands or other methods which can be used to find the usage of CPU. There are different methods to find system cpu usage, below are some of my analysis after lot of serach, Hope this will be very handy when you require to do some analysis based on system resource utilization.How to find which process is utilizing more memory of server
# ps axo %mem,comm,pid,euser | sort -nr | head -n 10 # ps aux | sort -nk +4 | tail
Print top ten process based on CPU usage
# ps -eo user,pcpu,pid,command | sort -r -k2 | head -11 # ps axo pcpu,comm,pid,euser | sort -nr | head -n 10 # ps -eo pcpu,pid,user,args | sort -k 1 -r | head -6 # ps aux |grep -v "%CPU"|sort +2nr|head -25
If -n is not working use the below
# ps aux | sort -b -k 4 | tail
Watch or Monitor the process in the interval of every two seconds
# watch --differences -n 2 'ps aux | sort -r -nk +4 | head'
To get the full command line
# ps -e -o rss=,args= | sort -b -k1,1n | pr -TW$COLUMNSThe above command can be used to find which process or the command is using cpu resource. It will specify the entire commandline or which command is using the system resources.
# ps -eo rss,vsz,pid,cputime,cmd --width 100 --sort rss,vsz | tail --lines 10
To monitor a specific process you can try
# top -p <processid1> -p <processid1>
Finding memory Leak
# ps aux --sort pmem
List all process threads
# ps -eLf # ps axmsList all threads for a particular process
# ps -C java -L -o pid,tid,pcpu,state,nlwp,args
Display process tree
# ps -ejH # ps axjfThe ps command also can be use to display process tree. The ps command example above, show step to use and ps command option to display Linux process in tree look alike view.
List Processes in a Hierarchy
# ps -e -o pid,args --forest
List the processes based on PIDs or PPIDs
# ps -ppid # ps -p # ps -f --ppid 12345
To get security info
# ps -eo euser,ruser,suser,fuser,f,comm,label # ps axZ # ps -eM
Print only the process IDs of syslogd
# ps -C syslogd -o pid=
Print only the name of PID 42
# ps -p 42 -o comm=
On AIX you can try the below
Displaying top CPU_consuming processes
# ps aux | head -1; ps aux | sort -rn +2 | head -10Displaying top 10 memory-consuming processes
# ps aux | head -1; ps aux | sort -rn +3 | headDisplaying the process in order of real memory use
# ps vx | head -1; ps vx | grep -v PID | sort -rn +6 | head -10Displaying process in order of nice value
# ps -eakl | sort -n +7Displaying the process in order of I/O
# ps vx | head -1; ps vx | grep -v PID | sort -rn +4 | head -10
The topic on Linux - Ps command monitoring top memory and process is posted by - Namo
Hope you have enjoyed, Linux - Ps command monitoring top memory and processThanks for your time