Main Menu

Search

Showing posts with label ps commands. Show all posts
Showing posts with label ps commands. Show all posts

LINUX: "ps" Command To List All Non Root User PID's / Processes (How To Doc)

Below "ps" Command can be used to list all non root user PID's and processes.
ps --ppid 2 -p 2 --deselect

Below is example output of above command.

# ps --ppid 2 -p 2 --deselect
  PID TTY          TIME CMD
    1 ?        00:00:33 init
  594 ?        00:00:04 udevd
  602 ?        00:00:00 server_httpd
  603 ?        00:00:00 server_httpd
 1616 ?        00:00:00 ora_w008_elctrl
 1652 ?        00:00:00 ora_w007_elctrl
 2019 tty1     00:00:00 mingetty


Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List Cumulative Used Memory In GB For All Processes Owned By All NON ROOT Users On Linux (How To Doc)

Below "ps" Command can be used to list cumulative used Memory in GB for all non root users on Linux Hosts.
ps -N -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done

Below is example output of above command which shows cumulative used memory for all non root users in GB.
ps -N -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done
21 GB

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List Cumulative Used Memory In GB For All Processes Owned By ROOT User On Linux (How To Doc)

Below "ps" Command can be used to list cumulative used Memory in GB for root user on Linux Hosts.
ps -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done

Below is example output of above command which shows cumulative used memory for root user in GB.

# ps -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))" GB"; done
4 GB


Products to which Article Applies

All Linux Operating Systems


LINUX: "ps" Command To List and Sort All Non Root User Processes By Total Memory Usage - In Descending Order PID's with Highest Total Memory Used At the Top (How To Doc)

Below "ps" command can be used to list and sort all non root user processes by total memory usage. Below command shows PID's with Highest total used Memory (in MB) owned by root user at the top and list goes down in descending order sorted by total memory usage.
ps -N -U root -wo rss=,user,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

Below is example output of above command.

# ps -N -U root -wo rss=,user,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done | more
0MB -
5959MB - oracle ora_dbw0_db
2710MB - appuser java
1957MB - oracle ora_mman_db
1156MB - orauser mysqld
853MB - oracle ora_cjq0_db
488MB - appuser java
467MB - orauser ora_mmon_db
441MB - orauser ora_smon_db
354MB - orauser ora_ckpt_db

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List and Sort ROOT User Processes By Total Memory Usage - In Descending Order PID's with Highest Total Memory Used At the Top (How To Doc)

Below "ps" command can be used to list and sort processes of root user by total memory usage. Below command shows PID's with Highest total used Memory (in MB) owned by root user at the top and list goes down in descending order sorted by total memory usage.
ps -U root -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

Below is example output of above command.

# ps -U root -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done | more
4495MB - java
34MB - OSWatcher.sh
33MB - OSWatcher.sh
32MB - OSWatcher.sh
10MB - python

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List and Sort Processes By Memory Usage - In Descending Order PID's with Highest Memory At the Top (How To Doc)

Below "ps" command can be used to list and sort processes by Memory usage / utilization. Below commands shows PID's with Highest Memory At the Top and list goes down in descending order sorted by memory usage.
ps aux --sort -rss

Below is example output of above command.

# ps aux --sort -rss
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
oracle    6436  0.0 18.5 10347256 6100908 ?    Ss   Sep10  13:07 ora_dbw0_db
root      8340  1.2 13.9 15710044 4604788 ?    Ssl  Sep10 402:07 /usr/java/jdk1.8.0_202-amd64/bin/java -Xms200M -Xmx8192M -server -XX:StringTableSize=2
oracle    6731 44.9  8.4 11729400 2776024 ?    Sl   Sep10 14584:50 /u01/app/oracle/java/bin/java -server -Xms512m -Xmx4096m -XX:MaxPermSize=512m -Dwebl
oracle    6412  0.0  6.0 10331576 2004148 ?    Ss   Sep10   0:29 ora_mman_db

Products to which Article Applies

All Linux Operating Systems

Linux: "ps" Command To Check Process Details Like Number Of Threads, State, Process Command, Start Time, Uptime, Arguments, CPU & Memory Usage (How To Doc)

Below ps command can be executed to get the details about process like number of threads, state, process command, start time, uptime, arguments, CPU & memory usage.
ps -eo pid,thcount,state,comm,lstart,etime,args,%cpu,%mem,cmd

Below is how to interpret each file.


thcount - thread count
state - process state
command - short description of process whether it is java, apache, httpd etc.
lstart - Exact date and time when the process started. Shown in Day Mon DD HH:MM:SS format
etime - Uptime of the process which is shows in Days, HH, MM and Seconds
etime - Startup arguments of the process.
%cpu - CPU utilized by the process.
%mem - Memory utilized by the process.
cmd - Complete command options of the process.

Below is sample output of java process using above ps command.
7413 215 S java  Tue Jul 30 09:55:46 2019 25-02:18:47 04:57:37 /usr/java/bin/  0.8  4.5 /usr/java/bin/java -Xms200M -Xmx8192M -server -XX:StringTableSize=27001 -XX:PermSize=128m -XX:MaxPermSize=384m -Xss256k -XX:+UseParallelOldGC -XX:SoftRefLRUPolicyMSPerMB=10000 


Products to which Article Applies


All UNIX environments

Additional References


LINUX: "ps" Command To Check The Complete Arguments Of Processes Like Java or Other Processes (How To Doc)

Usually Middleware applications or Application Server java process will have long startup arguments when the process startups. In some cases there may be need to check the complete arguments of java or other processes. For that scenarios below "ps" command can be used which will list the compute java process.


ps -auxww

Below is snippet of above command. As seen from below output we see complete startup arguments of the java process.


appuser    8928  5.2  3.6 5572052 1189192 ?     Sl   Feb15 1420:02 /app-share/java/bin/java -server -Xms512m -Xmx4096m -XX:MaxPermSize=512m -Dweblogic.Name=AdminServer -Djava.security.policy=/app-share/Middleware/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Djava.awt.headless=true -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8453,server=y,suspend=n -da:org.apache.myfaces.trinidad -da -Dplatform.home=/app-share/Middleware/wlserver_10.3 -Dwls.home=/app-share/Middleware/wlserver_10.3/server -Dweblogic.home=/app-share/Middleware/wlserver_10.3/server -Dcommon.components.home=/app-share/Middleware/testapp_common -Djrf.version=11.1.1 -Ddomain.home=/app-share/ovm-manager-3/machine1/base_adf_domain -Djrockit.optfile=/app-share/Middleware/testapp_common/modules/testapp.jrf_11.1.1/jrocket_optfile.txt -Dtestapp.server.config.dir=/app-share/ovm-manager-3/machine1/base_adf_domain/config/fmwconfig/servers/AdminServer -Dtestapp.domain.config.dir=/app-share/ovm-manager-3/machine1/base_adf_domain/config/fmwconfig -Digf.arisidbeans.carmlloc=/app-share/ovm-manager-3/machine1/base_adf_domain/config/fmwconfig/carml -Digf.arisidstack.home=/app-share/ovm-manager-3/machine1/base_adf_domain/config/fmwconfig/arisidprovider -Dtestapp.security.jps.config=/app-share/ovm-manager-3/machine1/base_adf_domain/config/fmwconfig/jps-config.xml -Dtestapp.deployed.app.dir=/app-share/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/tmp/_WL_user -Dtestapp.deployed.app.ext=/- -Dweblogic.alternateTypesDirectory=/app-share/Middleware/testapp_common/modules/testapp.ossoiap_11.1.1,/app-share/Middleware/testapp_common/modules/testapp.oamprovider_11.1.1 -Djava.protocol.handler.pkgs=testapp.mds.net.protocol -Dweblogic.jdbc.remoteEnabled=false -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/app-share/Middleware/patch_wls1035/profiles/default/sysext_manifest_classpath:/app-share/Middleware/patch_ocp360/profiles/default/sysext_manifest_classpath weblogic.Server
testapp    9192  0.0  0.1 8686200 53728 ?       Sl   Feb15  18:01 /app-share/java/bin/java -cp /app-share/ovm-manager-3/ovm_cli/classes:/app-share/ovm-manager-3/ovm_cli/lib/Model.jar:/app-share/ovm-manager-3/ovm_cli/lib/OvmClient.jar:/app-share/ovm-manager-3/ovm_cli/lib/slf4j-log4j12.jar:/app-share/ovm-manager-3/ovm_cli/lib/log4j.jar:/app-share/ovm-manager-3/ovm_cli/lib/org.apache.commons.logging.jar:/app-share/ovm-manager-3/ovm_cli/lib/sshd-core.jar:/app-share/ovm-manager-3/ovm_cli/lib/mina-core.jar:/app-share/ovm-manager-3/ovm_cli/lib/slf4j-api.jar -Dlog4j.configuration=file:./log4j.properties com.testapp.ovm.cli.CLIMain


Products to which Article Applies

All Linux and UNIX Environments.