Tag Info

Hot answers tagged

126

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


90

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


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


23

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


19

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


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

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


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.


12

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


12

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


10

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)


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


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


5

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.


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

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


3

without the -A, ps will only print the processes belonging to the current session. Think of it like "absolutely everything". On a related note -a does the same thing, but restricting it to the session-owner (username).


3

You might want to use -w with killall for that: -w, --wait Wait for all killed processes to die. killall checks once per second if any of the killed processes still exist and only returns if none are left. Note that killall may wait forever if the signal was ignored, had no effect, or if the ...


3

In the above, the ps aux runs first and its output is then redirected to the grep ls command. The grep ls command runs after ps aux. So why can ps know about the process that runs after it and has it in its output? You are writing about a logical order of command sequencing. If you get insights in bash proceedings you get to know that both ...


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

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


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



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