[G4] Finding a process that's keeping a file open
Joseph B. Gurman
gurman at gsfc.nasa.gov
Fri Feb 13 05:57:02 PST 2004
Vicki of Niue wrote:
>There is a way to find out via the terminal which process is hogging
>the image, and then kill that process, but right now I don't remember
>the procedure. Anyone else?
lsof -Fp | grep <filename>
where <filename> is the name of the annoyingly open file, will return
the process ID (pid) of the offending process; the output, however,
will be preceded by a "p," so to kill the process in one shell line,
you'd have to use awk or something similar. I'm lazy and un-awk-aware
enough to do it in two steps, the second being
kill -9 <pid>
where <pid> is the number following the "p" in the output from lsof.
CAUTION: I don't know what you'll be killing when you do that, so
proceed at your own risk. No warranty, written or implied, &c. NASA
and its interplanetary probes cannot be held responsible for loss,
breakage, or polishing of rocks. And so on.
HTH,
Joe Gurman
--
"I love deadlines. I love the whooshing sound they make as they go by."
- Douglas
Adams, 1952 - 2001
Joseph B. Gurman, NASA Goddard Space Flight Center, Solar Physics
Branch, Greenbelt MD 20771 USA
More information about the G4
mailing list