man ps
says:
If you want a repetitive update of the selection and the displayed information, use top(1) instead.
... however, in some cases, I don't like the output of top
- I would instead like to have the output exactly the same as ps axf
:
$ ps axf
PID TTY STAT TIME COMMAND
2 ? S 0:00 [kthreadd]
3 ? S 0:06 \_ [ksoftirqd/0]
6 ? S 0:00 \_ [migration/0]
11 ? S< 0:00 \_ [cpuset]
12 ? S< 0:00 \_ [khelper]
13 ? S< 0:00 \_ [netns]
15 ? S 0:00 \_ [sync_supers]
16 ? S 0:00 \_ [bdi-default]
17 ? S< 0:00 \_ [kintegrityd]
18 ? S< 0:00 \_ [kblockd]
19 ? S< 0:00 \_ [kacpid]
20 ? S< 0:00 \_ [kacpi_notify]
21 ? S< 0:00 \_ [kacpi_hotplug]
22 ? S< 0:00 \_ [ata_sff]
23 ? S 0:00 \_ [khubd]
24 ? S< 0:00 \_ [md]
26 ? S 0:00 \_ [khungtaskd]
27 ? S 0:01 \_ [kswapd0]
28 ? SN 0:00 \_ [ksmd]
29 ? S 0:00 \_ [fsnotify_mark]
30 ? S< 0:00 \_ [aio]
31 ? S 0:00 \_ [ecryptfs-kthrea]
32 ? S< 0:00 \_ [crypto]
36 ? S< 0:00 \_ [kthrotld]
38 ? S 0:00 \_ [scsi_eh_0]
39 ? S 0:00 \_ [scsi_eh_1]
40 ? S< 0:00 \_ [kmpathd]
...
Now, running ps axf
repeatedly is not a problem (plenty of suggestions on Repeat a Unix command every x seconds forever - Unix & Linux Stack Exchange); however, as the above snippet shows, its output can be quite larger than the size of a terminal window.
So I was wondering - is there a program which can run a command repeatedly, and collect its output, and display it in something like an ncurses
window? I'd ideally like to set ps axf
to refresh at half a second - and I'd like to have scrolling (given that the output will overflow terminal window bounds), however, such that if the text display starts vertically from, say, line 6 on top, it stays at that position - even if the latest output of the command has more (or less) lines of text in it than the previous one.
I hoped screen
may do something like this, but then, I don't think it implements any scrolling behavior... Is there a program out there that does something like this?
watch -n 0.5 ps axf
do what you want?watch
but unfortunately there's no scrolling as you describe it there.watch
, although, at least it keeps the start of output on top of terminal...C-a ESC
, then you can scroll).