Centos – lsof – age of file

centosfileslsof

The *nix command lsof gives you a list of open files. Is anyone aware of a way that would also list how long a particular file has been open? Either by using lsof or any other command. I'm using CentOS 5.3 and unfortunately I can't install additional repositories so I'd have to work from the default CentOS repos.

Thanks

Best Answer

If you have the pid, you can directly check in /proc/$pid/fd. It seems to be where file descriptors are created.

If you take a look at their creation date with a simple ls -lh, maybe you'll be able to know how long a particular file has been open.

Related Question