Questions tagged [lsof]

Lsof is a tool to list opened files by processes

Lsof is a tool to list on its standard output file information about files opened by processes.

107 questions
40
votes
5 answers

lsof - restrict output to physical files only - how?

How do I tell lsof I need to list only physical files (not sockets, not TCP/IP connections, only physical files)?
25
votes
2 answers

How to track all files a process opens in its lifetime

I am aware of using lsof for checking the files currently accessed by a process. Does there exist a way to see all files that an application opens in its lifetime?
Peter Smit
  • 1,699
18
votes
1 answer

What's the difference between `lsof -p | wc -l` and `ls /proc//fd | wc -l`?

Background: I'm playing around with monitoring the ulimit for running processes for a particular user. (I had occasionally seen processes that were getting started with an incorrect limit.) I asked a couple self-professed Linux gurus, and one…
Jared
  • 283
17
votes
4 answers

How can lsof report a higher number of open files than what ulimit says should be allowed?

How can lsof report more open files than what ulimit says is the limit? prod_web3(i-ca0b05aa):~$ sudo lsof | wc -l 4399 prod_web3(i-ca0b05aa):~$ ulimit -n 1024
Adam Nelson
  • 1,767
14
votes
3 answers

Link to a specific inode

I have a file that was deleted, but is still held open by a program. I found the inode number using lsof. How can I create a hard link back to that inode?
Jeff Ferland
  • 20,987
13
votes
4 answers

TCP monitoring on a server: comparing netstat vs lsof?

I'm monitoring the TCP stack on a server hoping to generically infer problems with application on the box. My first inclination is to measure the number of sockets in all reported states (LISTEN,ESTABLISHED,FIN_WAIT2,TIME_WAIT, etc) and detect some…
ericslaw
  • 1,592
13
votes
5 answers

How to make my boss understand that a server fault is a bad thing?

I'm currently working in Tokyo for a smaller company that has just started serious online business. Recently we have been hitting the maximum open files issue on a rented VPS server causing services to stop functioning temporarily (more or less…
Ben
  • 247
13
votes
3 answers

On Linux, how can I see how far through a file a process is?

If I have a piped command such as cat myfile | processor_application where processor_application is something reading from standard in, in chunks, to process, is it possible to see how far through the file cat has got? Possibly using…
wodow
  • 600
13
votes
3 answers

How to track down a file descriptor leak?

I have a java process (Glassfish) which is leaking file descriptors. I know this because I get the helpful java.io.IOException: Too many open files exception. I can look in /proc/PID#/fd and see all the open file descriptors. When I use lsof I…
cclark
  • 567
12
votes
2 answers

non-cpu-intensive alternative to lsof?

We run an Apache Cassandra cluster where each host has a few hundred thousand files open at any given time. We'd like to be able to get a count of open files at periodic intervals and feed this number into graphite, but when we run lsof under…
12
votes
4 answers

Running lsof -i shows a lot of connections in CLOSE_WAIT ? Should I worry

So I am running lsof -i | wc -l periodically and it is telling me that out of 420 lines, between 240 and 255 are in CLOSE_WAIT state. How does TCP connections enter this state? Should I be worried and how should I troubleshoot it?
user20414
  • 223
11
votes
1 answer

How can I observe what nginx is doing? (to solve: "1024 worker_connections are not enough")

I have a very low traffic site running on nginx, with 4 workers, 1024 connections each. Every several hours I start seeing in the error log "1024 worker_connections are not enough", and my site slows down / becomes flakey. A nginx restart solves the…
John Bachir
  • 2,394
9
votes
3 answers

Getting PID from lsof list

I have a react-native application and I want to write a script for start test version. I need to shotdown the :8081 port if it is alive. The command: lsof -i :8081 kill -9 The lsof getting back this result: COMMAND PID USER FD …
8
votes
3 answers

lsof for files opened by other users

How do I see the list of files open (lsof) in a specific directory and by other users? I can do lsof +D /path, but that only shows current user's files. Any way to see if other users have opened files in a directory?
Ash
8
votes
3 answers

lsof runs very slow in my server

I'm running lsof in one of my Linux server to check if one file (/tmp/incoming_data.txt) in the ext3 system is opened by other programs. My server has lots of TCP connection on it. The weird thing is the execution of 'sudo lsof' takes about two…
James Gan
  • 406
1
2 3 4 5 6 7 8