To be honest that sounds like a pretty bad set up if you need to manually delete files when you know there&#x27;s a chance that the system is not only operating on them, but also not stable enough to handle exceptions arising from accessing them.<p>But arguments about your system aside, you could mitigate user error by installing <i>lsof</i>[1]. eg<p><pre><code>    $ lsof &#x2F;bin&#x2F;bash
    COMMAND   PID USER  FD   TYPE DEVICE SIZE&#x2F;OFF NODE NAME
    startkde 1496  lau txt    REG   0,18   791304 6626 &#x2F;usr&#x2F;bin&#x2F;bash
    bash     1769  lau txt    REG   0,18   791304 6626 &#x2F;usr&#x2F;bin&#x2F;bash

</code></pre>
[1] <a href="https:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=lsof&amp;sektion=8&amp;manpath=linux" rel="nofollow">https:&#x2F;&#x2F;www.freebsd.org&#x2F;cgi&#x2F;man.cgi?query=lsof&amp;sektion=8&amp;man...</a><p>You might even be able to script it so you&#x27;ll only delete a file if it&#x27;s not in use. eg<p><pre><code>    saferm() {
        lsof $1 || rm -v $1
    }
</code></pre>
If you do come to rely on that then you&#x27;ll probably want to do some testing against edge cases; just to be safe.