lsof works under linux and MacOS X and will help you figure out what files are open.

lsof | grep ‘mysqld’

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
 

2 Responses to Linux: use lsof to find which files are open by a process

  1. Stoner says:

    Instead of listing every open file handle on a system and grepping through it, lsof lets you specify a list of PIDs to show open file handles for. It’s the -p parameter.

    lsof -p

    Of course, it helps to run this using sudo or as the user running the mysqld process, otherwise you get something like this:

    [jstoner@mars ~]$ /usr/sbin/lsof -p 1866
    COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
    mysqld 1866 mysql cwd unknown /proc/1866/cwd (readlink: Permission denied)
    mysqld 1866 mysql rtd unknown /proc/1866/root (readlink: Permission denied)
    mysqld 1866 mysql txt unknown /proc/1866/exe (readlink: Permission denied)
    mysqld 1866 mysql NOFD /proc/1866/fd (opendir: Permission denied)

  2. jon says:

    Clearly I should have checked the man page. Thanks for the tip.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>