Hot answers tagged

130

The correct syntax, which returns the same output, would be: ps u There is a good reason why modern syntax for ps is a mess. Historically, there were two incompatible version of ps. Options with a leading dash were inherited from the AT&T Unix version of ps. Options without a leading dash were inherited from BSD. The version of ps that Linux ...


122

$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND timothy 29217 0.0 0.0 11916 4560 pts/21 S+ 08:15 0:00 pine root 29505 0.0 0.0 38196 2728 ? Ss Mar07 0:00 sshd: can [priv] can 29529 0.0 0.0 38332 1904 ? S Mar07 0:00 sshd: can@notty USER = user owning the process PID = ...


84

The ps command historically had wildly different syntax in BSD and System V Unix. In BSD ps, the u option (no dash) takes no parameter and shows the "user-oriented output" with the additional columns. In SunOS ps, the -u option (with dash) takes a username as parameter and only includes processes owned by that user, but without changing the display format. ...


39

% sudo ls -l /proc/PID/exe eg: % ps -auxwe | grep 24466 root 24466 0.0 0.0 1476 280 ? S 2009 0:00 supervise sshd % sudo ls -l /proc/24466/exe lrwxrwxrwx 1 root root 0 Feb 1 18:05 /proc/24466/exe -> /package/admin/daemontools-0.76/command/supervise


22

grep's -v switch reverses the result, excluding it from the queue. So make it like: ps aux | grep daemon_name | grep -v "grep daemon_name" | awk "{ print \$2 }" Upd. You can also use -C switch to specify command name like so: ps -C daemon_name -o pid= The latter -o determines which columns of the information you want in the listing. pid lists only the ...


21

This can happen if the username is longer than 8 characters.


20

pstree ${pid} where ${pid} is the pid of the parent process. On gentoo pstree is in the package "psmisc," apparently located at http://psmisc.sourceforge.net/


18

You can use a character class trick. "[d]" does not match "[d]" only "d". ps aux | grep [d]aemon_name | awk "{ print \$2 }" I prefer this to using | grep -v grep.


17

From the ps manpage: S Interruptible sleep (waiting for an event to complete) For BSD formats and when the stat keyword is used, additional characters may be displayed: s is a session leader l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)


15

In Linux the command: ps -aux Means show all processes for all users. You might be wondering what the x means? The x is a specifier that means 'any of the users'. So you could type this: ps -auroot Which displays all the root processes, or ps -auel which displays all the processes from user el. The technobabble in the 'man ps' page is: "ps -aux ...


15

Try this: ls -l /proc/<PID>/cwd


12

This should work: ps h --ppid $PID -o pid


12

Avoid parsing ps's output if there are more reliable alternatives. pgrep daemon_name pidof daemon_name


9

The pstree is a very good solution, but it is a little bit reticent. I use ps --forest instead. But not for a PID (-p) because it prints only the specific process, but for the session (-g). It can print out any information ps can print in a fancy ASCII art tree defining the -o option. So my suggestion for this problem: ps --forest -o pid,tty,stat,time,cmd ...


9

It is normal for Mac OS X. It used to be normal on almost all Unix-oid systems. It runs as root without sudo because the ps binary is set-uid to run as root (e.g. on my 10.4 system): % ls -l $(which ps) -rwsr-xr-x 1 root wheel 31932 Mar 20 2005 /bin/ps (the s in place of the the user-owner x column means that it is set-uid (and user-executable), the ...


8

pwdx $pid This gives you the Current Working Directory of the pid, not its absolute path. usually the which command will tell you which is being invoked from the shell. #>which vlc /usr/bin/vlc


8

I had that happen once when an NFS server went down. The fact that it's hung trying to read information about pid 17398, and pid 17398 is in D (disk wait) state, suggests that could be the cause for you too. read(6, "Name:\tconvert\nState:\tD (disk sle"..., 1023) = 664 open("/proc/17398/cmdline", O_RDONLY) = 6 If you do have NFS mounts, I think the ...


7

Derived rom HUB's answer: readlink /proc/<PID>/cwd or even readlink /proc/$(pgrep <program_name>)/cwd


7

One way is ps -ef


6

Also this might be helpful: Process state codes: R running or runnable (on run queue) D uninterruptible sleep (usually IO) S interruptible sleep (waiting for an event to complete) Z defunct/zombie, terminated but not reaped by its parent T stopped, either by a job control signal or because it is being traced Some extra modifiers: < ...


6

man ps says cputime TIME cumulative CPU time, "[dd-]hh:mm:ss" format. (alias time). So your Java process has been running for 1184018564 CPU days (about 3,243,886 CPU years), OR ... something bad has happened. It is Ubuntu bug #859311 associated with long-running multi-threaded processes.


6

There is PDFjam that brings pdfnup and allows you to do basically the same things as psnup.


6

ps axuwfw This is a combination of several BSD-style options (all of which are in the manual page, man ps): a: include processes from other users x: include processes with no terminal u: show user-oriented information fields w: wide output (132 columns instead of 80) f: "forest": tree view of processes w: even wider output (no limit at all) In other ...


5

Here is my version that runs instantly (because ps executed only once). Works in bash and zsh. pidtree() ( [ -n "$ZSH_VERSION" ] && setopt shwordsplit declare -A CHILDS while read P PP;do CHILDS[$PP]+=" $P" done < <(ps -e -o pid= -o ppid=) walk() { echo $1 for i in ${CHILDS[$1]};do walk ...


5

From the ps(1) manpage, STANDARD FORMAT SPECIFIERS section: c C processor utilization. Currently, this is the integer value of the percent usage over the lifetime of the process. (see %cpu).


4

First, I use Linux, not Windows, so I can't test this, but I think something like this is right. (I'm almost tempted to tell you to install Linux inside a virtual machine for this, since stuff like this is sooo much easier with a grown-up operating system, but anyway, here goes my best bet for using Windows.) First, open a Command/Dos prompt. To navigate ...


4

In linux procps, the column labeled "PRI" in ps -l is -o opri. Examining output.c shows half a dozen different priority output types: // "priority" (was -20..20, now -100..39) // "intpri" and "opri" (was 39..79, now -40..99) // "pri_foo" -- match up w/ nice values of sleeping processes (-120..19) // "pri_bar" -- makes RT pri show as negative ...


4

You could use a program called Process Monitor. This program allows you to do what you want... Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. It combines the features of two legacy Sysinternals utilities, Filemon and Regmon, and adds an extensive list of enhancements ...


4

The comm field (also /proc/$pid/comm) is limited by the kernel to 16 bytes total (15 characters + terminating NUL byte). If the system is Linux and you own the process (or are root), you can obtain the executable path by following /proc/$pid/exe using the readlink command. Otherwise, you will have to use the cmd field (aliases args, command). On Linux it's ...


4

I guess you are looking for the -o argument: -o format: user-defined format. format is a single argument in the form of a blank-separated or comma-separated list, which offers a way to specify individual output columns. The recognized keywords are described in the STANDARD FORMAT SPECIFIERS section below. Headers may be renamed (ps -o ...



Only top voted, non community-wiki answers of a minimum length are eligible