我inotifywait
用于放置文件的事件触发器。
当很多文件被 观看时inotifywait
,当max_user_watches
超过时,会出现以下错误。
因 inotify 监视而终止。#012考虑增加 /proc/sys/fs/inotify/max_user_watches
需要调整/proc/sys/fs/inotify/max_user_watches
,但是可以查看当前文件监视号吗?
有没有办法像文件描述符中的 file-nr一样检查?
作为工作的一部分,我使用几个不同的 Nodejs 实时服务器,并且我的工具/工作流程中似乎存在某种泄漏,导致文件观察器随着时间的推移而累积,直到达到系统限制。然后我收到以下 cli 错误:
Error from chokidar (<path-to-folder>): Error:
ENOSPC: System limit for number of file watchers reached, watch '<path-to-folder>/<filename>'
Run Code Online (Sandbox Code Playgroud)
我发现以下命令应该返回使用的 wile 观察者的数量:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify -printf '%hinfo/%f\n' 2>/dev/null | xargs cat | grep -c '^inotify'
Run Code Online (Sandbox Code Playgroud)
它返回 515160,尽管我似乎已经关闭了所有实时服务器。我有两组问题:
我运行的是 Debian 11