Tag Info

Hot answers tagged

125

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 ...


83

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. ...


79

$ 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 = ...


21

% 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


19

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


18

grep's -v switch reverses the result, excluding it from the queue. So make it like: ps aux | grep daemon_name | grep -v grep | 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 process id ...


17

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/


14

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.


13

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 ...


11

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


11

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


11

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


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 ...


9

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)


7

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 ...


6

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


6

One way is ps -ef


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

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

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

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 ...


4

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 ...


4

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


3

pgrep supports various conditions: pgrep -x -u "user" "command" Replace -x with -f to also match the arguments; add -l to display command line. You can also read the command line directly from /proc/PID/cmdline (null-separated): if pids=$(pgrep -x -u "user" "command"); then for pid in $pids; do tr "\0" " " < /proc/$pid/cmdline; echo ...


3

killall is your friend killall skype You only need to use sudo if the process is owned by another user e.g. sudo killall gdm


3

BSD options to ps do not take a dash. ps aux


3

It should (and did for me) display that warning whether or not it's piped to grep. The real issue is the -aux switch. The manpage says: Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a ...


3

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 ...


3

#!/usr/bin/awk -f # NOTE: This example takes only CPU load as input. Use it like this: # # cat log.txt | awk '$1 == "1923" {print $9}' | awk -f rolling-average.awk BEGIN { freq = 10; sum = 0; max = 0 } { i = NR % freq if (NR > freq) sum -= data[i] sum += (data[i] = $1) } NR >= freq { avg = sum/freq print "average ...


3

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 ...



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