codeaprendiz.github.io

DevOps Essentials

View on GitHub

ps

NAME

ps – process status

SYNOPSIS

ps [-AaCcEefhjlMmrSTvwXx] [-O fmt -o fmt] [-G gid[,gid…]] [-g grp[,grp…]] [-u uid[,uid…]] [-p pid[,pid…]] [-t tty[,tty…]] [-U user[,user…]]

ps [-L]

DESCRIPTION

The ps utility displays a header line, followed by lines containing information about all of your processes that have controlling terminals.

A different set of processes can be selected for display by using any combination of the -a, -G, -g, -p, -T, -t, -U, and -u options. If more than one of these options are given, then ps will select all processes which are matched by at least one of the given options.

For the processes which have been selected for display, ps will usually display one line per process. The -M option may result in multiple output lines (one line per thread) for some processes. By default all of these output lines are sorted first by controlling terminal, then by process ID. The -m, -r, and -v options will change the sort order. If more than one sorting option was given, then the selected processes will be sorted by the last sorting option which was specified.

For the processes which have been selected for display, the information to display is selected based on a set of keywords (see the -L, -O, and -o options). The default output format includes, for each process, the process’ ID, controlling terminal, CPU time (including both user and system time), state, and associated command.

OPTIONS

EXAMPLES

It is used to get the process status.

set of options for viewing all the processes running on a system is

ps -ef | less

The processes shown by ps can be limited to those belonging to any given user by piping the output through grep, a filter that is used for searching text. For example, processes belonging to a user with a username adam can be displayed with the following:

ps -ef | grep adam

-p, -o

$ ps -p 14491 -o %cpu,%mem,cmd
%CPU %MEM CMD
 0.0  0.4 /apps/resources/java/jdk1.7.0_15/bin/java -Xms512m -Xmx1024m -XX:MaxPermSize=1024m -jar slave.jar

-p selecting by pid

$ ps -p 14491 -o %cpu,%mem,cmd
%CPU %MEM CMD
 0.0  0.4 /apps/resources/java/jdk1.7.0_15/bin/java -Xms512m -Xmx1024m -XX:MaxPermSize=1024m -jar slave.jar