[Linux] Where does my process log?
How many times you need to suppose where your long running process logs, for example a database instance or a weblogic container, and you spend a lot of times in finding it?
With lsof you can find a lot of useful information about open files!
- Oracle Linux Server 7.8
- bash, version 4.2.46
Find all open files of a process
In this example, you can find all the open files of a process:
As you can see, firstly we find the PID of the process that we want to analyze, secondly we use it as argument of lsof to find all open files of that process.
Obviously we can grep the output to find the log:
As you can see, with only two commands we find where that process logs.
Find which user is using a filesystem
Now, suppose the you want to unmount a filesystem, but it gives error, because some user is using it.
You can find it easily with lsof!
For example, in this way I checkout easily which process is using it!
This is how to interpret the output:
That’s it, you can use lsof in a lot of useful manners: checking open files of a process, which process is using a directory, etc…
I found lsof very useful and powerful.