Questions tagged [lsof]

Unix command that lists the files, sockets, and other file-descriptors that processes have open.

236 questions
110
votes
5 answers

See what process is accessing a file in Mac OS X

Note: This quesiton is NOT show me which files are in use. The file is not currently in use. The file will be in use at some unknown point in the future. At that point, I want to know what process accessed the file. I would like to be able to track…
JPC
  • 8,096
  • 22
  • 77
  • 110
108
votes
6 answers

lsof survival guide

lsof is an increadibly powerful command-line utility for unix systems. It lists open files, displaying information about them. And since most everything is a file on unix systems, lsof can give sysadmins a ton of useful diagnostic data. What are…
Hans Sjunnesson
  • 21,745
  • 17
  • 54
  • 63
87
votes
2 answers

lsof print numeric ports

How do you get lsof to produce numeric port information instead of attempting to resolve the port to service name? For example, I want TCP *:http (LISTEN) to give me TCP *:80 (LISTEN) in-fact if at all possible I never want to see another service…
Coder Guy
  • 1,843
  • 1
  • 15
  • 21
41
votes
4 answers

In Mac OS X, how can I get an accurate count of file descriptor usage?

On Linux, ulimit -n can be used to change or view the limit on the number of file descriptors for a process, and lsof -p nnn | wc -l seems to consistently report the actual file descriptor usage. But on Mac OS X, lsof -p nnn | wc -l can return a…
jfklein
  • 877
  • 1
  • 11
  • 13
37
votes
5 answers

How to close a file descriptor from another process in unix systems

You can use command lsof to get file descriptors for all running processes, but what I would like to do is to close some of those descriptors without being inside that process. This can be done on Windows, so you can easily unblock some…
Seb
  • 17,141
  • 7
  • 38
  • 27
24
votes
2 answers

Address already in use but nothing in netstat or lsof

I try to start the Python SimpleHTTPServer on port 7054 : $ sudo python -m SimpleHTTPServer 7054 ... socket.error: [Errno 98] Address already in use So, I ran the following commands : $ sudo netstat -ntpu | grep 7054 $ sudo lsof -i -n -P | grep…
pgmillon
  • 361
  • 1
  • 2
  • 6
23
votes
3 answers

Seeing too many lsof can't identify protocol

I have a Java process/app. When I run /usr/sbin/lsof -p on that java process, I see a lot of "can't identify protocol". Also, interestingly, File descriptors(FDs) are increasing at a very steady rate. And those FDs that are being created are…
Johnny
  • 231
  • 1
  • 2
  • 4
21
votes
1 answer

Can lsof show open ports on alpine linux?

I have a spring boot app running in alpine linux listening on port 8080. However, when I do: $ lsof $ lsof -i 8080 it doesn't show the open ports. Do you know what I am doing wrong? It almost seems that lsof on alpine linux isn't honoring any…
user674669
  • 10,681
  • 15
  • 72
  • 105
17
votes
3 answers

What does the FD column of pipes listed by lsof mean?

I'm using the following command to get a list of pipes: lsof | grep PIPE I want to know what the values of the FD column mean (the 5th one https://i.stack.imgur.com/zkjCn.png). I think that r and w mean read and write, respectively, but what does…
William
  • 331
  • 1
  • 3
  • 12
15
votes
2 answers

How to clean up after subprocess.Popen?

I have a long-running python script with a perl worker subprocess. Data is sent in and out of the child proc through its stdin and stdout. Periodically, the child must be restarted. Unfortunately, after a while of running, it runs out of files…
dkuebric
  • 415
  • 1
  • 3
  • 6
14
votes
1 answer

Troubleshooting 'Too many files open' with lsof

I have a Java application running on Linux with PID 25426. When running lsof -p 25426, I noticed: java 25426 uid 420w FIFO 0,8 0t0 273664482 pipe java 25426 uid 421r FIFO 0,8 0t0 273664483 pipe java …
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
14
votes
1 answer

Script with lsof works well on shell not on cron

I have a small script do count open files on Linux an save results into a flat file. I intend to run it on Cron every minute to gather results later. Script follows: /bin/echo "Timestamp: ` date +"%m-%d-%y %T"` Files: `lsof | grep app | wc -l`" And…
Neill Lima
  • 331
  • 3
  • 11
13
votes
2 answers

Check for open files with Python in Linux

I'm looking for a way to determine which files are open in my whole system (Linux) using Python. I can't find any module that does this. Or maybe the only way is with the command lsof?
John Lapoya
  • 582
  • 1
  • 8
  • 21
13
votes
2 answers

How many open files for each process running for a specific user in Linux

Running Apache and Jboss on Linux, sometimes my server halts unexpectedly saying that the problem was Too Many Open Files. I know that we might set a higher limit for nproc and nofile at /etc/security/limits.conf to fix the open files problem, but I…
tesla-rules
  • 130
  • 1
  • 1
  • 5
13
votes
2 answers

lsof should give all open files for a set of pids

I have 30 instances of a process running on a server and want to log open files for each process for analysis. I ran the following command: * ps auwwx | grep PROG_NAME | awk '{print $2}' | xargs lsof -p | less It complaints that, "lsof: status…
user1071840
  • 3,522
  • 9
  • 48
  • 74
1
2 3
15 16