What's the fastest way using lsof to find a single open file?

前端 未结 4 735
再見小時候
再見小時候 2021-01-05 16:13

I\'m trying to test a single file if it is open using lsof. Is there a faster way than this?

$result = exec(\'lsof | grep filename | wc -l\');

if($result &         


        
4条回答
  •  悲&欢浪女
    2021-01-05 17:14

    Use fuser. It returns non-zero if any of the files specified are in use, and zero if they're all available.

提交回复
热议问题