News for hackers. Stuff that matters.
Re:Show HN: Watch what files any Linux process accesses by hnlmorg on Tuesday June 09, 2020 @03:27AM (#23464543)
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)

Re:Show HN: Watch what files any Linux process accesses by simcop2387 on Tuesday June 09, 2020 @04:17AM (#23464767)
Pv supports this directly with -d pid, http://manpages.ubuntu.com/manpages/bionic/man1/pv.1.html
Re:Show HN: Watch what files any Linux process accesses by hnlmorg on Tuesday June 09, 2020 @07:44AM (#23465726)
I learn something new every day. Thank you
Re:Show HN: Watch what files any Linux process accesses by simcop2387 on Tuesday June 09, 2020 @08:05PM (#23472427)
Yea it's really nice for making a progress bar for things like cp, mv, etc.
Re:Show HN: Watch what files any Linux process accesses by im3w1l on Tuesday June 09, 2020 @11:28AM (#23467470)
The main drawback of this is that the program may access a file too quickly for a polling strategy to notice.
Re:Show HN: Watch what files any Linux process accesses by Wowfunhappy on Tuesday June 09, 2020 @09:52AM (#23466645)
On 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]
Re:Show HN: Watch what files any Linux process accesses by hnlmorg on Tuesday June 09, 2020 @10:22AM (#23466899)
It 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.

Re:Show HN: Watch what files any Linux process accesses by thebruce87m on Tuesday June 09, 2020 @06:30AM (#23465353)
Admittedly 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

Edit: By monitoring things, I mean like finding how far through a dd is after you have started it already.

Re:Show HN: Watch what files any Linux process accesses by PuffinBlue on Tuesday June 09, 2020 @09:06AM (#23466319)
Similarly, 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.