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.

102 questions
36
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)?
Vladislav Rastrusny
  • 2,581
  • 12
  • 39
  • 56
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,649
  • 4
  • 21
  • 37
16
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
  • 263
  • 2
  • 6
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,239
  • 2
  • 61
  • 85
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,562
  • 2
  • 13
  • 15
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
  • 590
  • 1
  • 5
  • 18
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
  • 2
  • 6
  • 14
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…
Michael Martinez
  • 2,543
  • 3
  • 20
  • 31
12
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,557
  • 3
  • 13
  • 12
11
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
  • 227
  • 2
  • 6
10
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,344
  • 7
  • 29
  • 37
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
  • 376
  • 1
  • 5
  • 10
7
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
  • 173
  • 1
  • 1
  • 3
6
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 …
PumpkinSeed
  • 295
  • 2
  • 5
  • 12
6
votes
1 answer

unmounted logical volume is "busy"?

I'm trying to shrink an ext4 filesystem on a CentOS 6 server. I did a lazy unmount of the filesystem while I waited for some processes to finish running. They've all finished running but I can't seem to do anything with the filesystem. How can I…
Jayen
  • 1,827
  • 3
  • 16
  • 27
1
2 3 4 5 6 7