5 ms·
Not taking anything away from the worth of this tool but if you do happen to find yourself needing to quickly inspect which files a process has open you can do
by hnlmorg 6y ago
Not taking anything away from the worth of this tool but if you do happen to find yourself needing to quickly inspect which files a process has open you can do so using the /proc file system:
ls -l /proc/$PID/fd/
Additionally you can also use the /proc file system to display where the cursor is in those files by outputting the contents of
/proc/$PID/fdinfo/$FD
which is handy if you have a long running process but forgot to pipe it into `pv` (or any other long running ingest that lacks a progress UI)
(Both tricks are Linux only)
- simcop2387 6y agoPv supports this directly with -d pid, http://manpages.ubuntu.com/manpages/bionic/man1/pv.1.html http://manpages.ubuntu.com/manpages/bionic/man1/pv.1.html
- hnlmorg 6y agoI learn something new every day. Thank you
- simcop2387 6y agoYea it's really nice for making a progress bar for things like cp, mv, etc.
- thebruce87m 6y agoAdmittedly my Linux skills are basic so I’m not sure how it compares, but I like the utility “progress” for monitoring things: https://github.com/Xfennec/progress/blob/master/README.md https://github.com/Xfennec/progress/blob/master/README.md Edit: By monitoring things, I mean like finding how far through a dd is after you have started it already.
- PuffinBlue 6y agoSimilarly, and perhaps obviously to some, you can use that to check how many files that process has open in total: ls -al /proc/$PID/fd/ | wc -l Useful for actually knowing what that specific process has open and is respecting your Max Open Files settings. I'm looking at you Influx.
- Wowfunhappy 6y agoOn Mac, there's also lsof. (Also on Linux? I always assumed it was just a standard Unix tool, but maybe not?) lsof -c [process name] lsof -p [pid]
- hnlmorg 6y agoIt is available for Linux however it's not always part of the base install of every distribution (but a worthwhile install none-the-less). Not taking anything away from lsof as I do use it myself but I do also think there is also merit in learning the /proc file system too because it helps illuminate some of the not-so-hidden magic behind Linux. Even if you then still find lsof or similar become your preferred utility.
- im3w1l 6y agoThe main drawback of this is that the program may access a file too quickly for a polling strategy to notice.