title: Automatically solve rm cannot remove path : device or resource busy error
body: <p>I am trying to remove a directory <code>/path/to/dir</code> using the <code>rm -rf</code> command.
  Unfortunately I get the error</p>
  <pre><code>rm: cannot remove '/path/to/dir/.nfsdda293a660f276ca0000000a': Device or resource busy
  </code></pre>
  <p>After a little bit of research, I realized that I need to find which process is using this file before I can delete it:</p>
  <pre><code>lsof /path/to/dir/.nfsdda293a660f276ca0000000a
  </code></pre>
  <p>which will return something with the PID associated with the process:</p>
  <pre><code>COMMAND   PID
  python    28594
  </code></pre>
  <p>I then kill the PID and try again to delete, but I still get the initial error.</p>
  <p>How to force the script to delete <code>/path/to/dir</code> automatically within a script, without manual intervention?</p>