0
When I run top
in Cygwin I get:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
I would like to extract these columns for all processes:
PID PPID S COMMAND
ps
gives PID, PPID, and COMMAND, but how do I get the 'S' column for all processes?
Edit:
I cannot use what I use on GNU/Linux:
$ ps -e -o pid,ppid,state,comm
ps: unknown option -- o
Try `ps --help' for more information.
$ ps --version
ps (cygwin) 1.7.33
Show process statistics
Copyright (C) 1996 - 2014 Red Hat, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ps --help
Usage: ps [-aefls] [-u UID] [-p PID]
Report process status
-a, --all show processes of all users
-e, --everyone show processes of all users
-f, --full show process uids, ppids
-h, --help output usage information and exit
-l, --long show process uids, ppids, pgids, winpids
-p, --process show information for specified PID
-s, --summary show process summary
-u, --user list processes owned by UID
-V, --version output version information and exit
-W, --windows show windows as well as cygwin processes
With no options, ps outputs the long format by default
procps
:
version: 3.2.8-3
That seems to work, but is awfully slow (600 ms vs, ps' 20 ms). Can
top
be sped up? – Ole Tange – 2015-03-23T15:45:16.537600 ms (or 0,6 sec) is about the same performance I get; top is slow, not awk. Also, on my Debian it goes really fast. I tried strace to find out what kernel calls it was lagging on, but that gave no much insight. I suppose the interaction between CygWin and the underlying Windows OS is causing the delay. No clue why ps is much faster though. – agtoever – 2015-03-23T15:58:11.040
With a bit more hacking (batch script) you could read out all
/proc/<pid>/status
files, showing all the columns you need. – agtoever – 2015-03-23T16:02:03.020grep State /proc/*/status
seems pretty fast. – Ole Tange – 2015-03-23T16:08:08.393