how to get the number of inotify watches in use
Clash Royale CLAN TAG#URR8PPP
I use inotifywait
for event trigger which put file.
When many files are watched by inotifywait
, when max_user_watches
is exceeded, the following error occurs.
Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches
It is necessary to tune /proc/sys/fs/inotify/max_user_watches
, but is it possible to check the current file watch number?
Is there a way to check like file-nr in file descriptor?
linux inotify
add a comment |
I use inotifywait
for event trigger which put file.
When many files are watched by inotifywait
, when max_user_watches
is exceeded, the following error occurs.
Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches
It is necessary to tune /proc/sys/fs/inotify/max_user_watches
, but is it possible to check the current file watch number?
Is there a way to check like file-nr in file descriptor?
linux inotify
add a comment |
I use inotifywait
for event trigger which put file.
When many files are watched by inotifywait
, when max_user_watches
is exceeded, the following error occurs.
Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches
It is necessary to tune /proc/sys/fs/inotify/max_user_watches
, but is it possible to check the current file watch number?
Is there a way to check like file-nr in file descriptor?
linux inotify
I use inotifywait
for event trigger which put file.
When many files are watched by inotifywait
, when max_user_watches
is exceeded, the following error occurs.
Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches
It is necessary to tune /proc/sys/fs/inotify/max_user_watches
, but is it possible to check the current file watch number?
Is there a way to check like file-nr in file descriptor?
linux inotify
linux inotify
edited Feb 20 at 23:22
mosvy
7,7121530
7,7121530
asked Feb 3 at 7:41
Soushi HirutaSoushi Hiruta
62
62
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I wish I was able to answer with something smarter, but the only way I found to count the inotify(7)
watches set by a user is this:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify
-printf '%hinfo/%fn' 2>/dev/null |
xargs cat | grep -c '^inotify'
Change "$USER"
with the actual user you want info about; "`id -u`"
for the current user. Notice that the max_user_watches
is a per-user limit, not per process, or per inotify instance / file descriptor.
This will first find
all open file descriptors created by inotify_init*(2)
, and will then look into the corresponding /proc/PID/fdinfo/FD
file for the info about the watch descriptors added with inotify_add_watch(2)
to each of them (look into the proc(5)
manpage under /proc/[pid]/fdinfo/
for a description of the inotify-specific entries). The -c
option of grep
will let it print a count of all lines that match a pattern.
Note: the counter for inotify_watches
is kept just like other per-user counters in a struct ucounts
referenced from the user namespace structure -- see include/linux/user_namespace.h
; but I wasn't able to find any interface exposing those counters to userland.
add a comment |
I cobbled together this little script based on @mosvy's answer.
$ inotify-consumers
INOTIFY
WATCHER
COUNT PID CMD
----------------------------------------
7111 3079 node /home/carlerik/dev/nimble-frontend/node_modules/.bin/webpack --config config/webpack.dev.js
79 1541 /usr/lib/gnome-settings-daemon/gsd-xsettings
30 1664 /usr/lib/gvfs/gvfsd-trash --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
14 1630 /usr/bin/gnome-software --gapplication-service
14 1191 /lib/systemd/systemd --user
10 1371 /usr/bin/gnome-shell
9 2459 update-notifier
7 1635 nautilus-desktop
5 1191 /lib/systemd/systemd --user
2 1536 /usr/lib/gnome-settings-daemon/gsd-sound
2 1452 /usr/lib/evolution/evolution-source-registry
2 1429 ibus-daemon --xim --panel disable
2 1248 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1 1863 /usr/lib/gnome-terminal/gnome-terminal-server
1 1713 /usr/lib/evolution/evolution-addressbook-factory
1 1678 /usr/lib/ibus/ibus-engine-simple
1 1625 /usr/lib/evolution/evolution-calendar-factory
1 1560 /usr/lib/gnome-settings-daemon/gsd-housekeeping
1 1556 /usr/lib/gnome-settings-daemon/gsd-color
1 1499 /usr/lib/gvfs/gvfs-afc-volume-monitor
1 1487 /usr/lib/gnome-online-accounts/goa-identity-service
1 1480 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
1 1460 /usr/lib/gnome-online-accounts/goa-daemon
1 1440 /usr/lib/ibus/ibus-portal
1 1435 /usr/lib/ibus/ibus-x11 --kill-daemon
1 1433 /usr/lib/ibus/ibus-dconf
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1371 /usr/bin/gnome-shell
1 1352 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 12287 /home/carlerik/.sdkman/candidates/java/current/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dcl
1 1191 /lib/systemd/systemd --user
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498393%2fhow-to-get-the-number-of-inotify-watches-in-use%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I wish I was able to answer with something smarter, but the only way I found to count the inotify(7)
watches set by a user is this:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify
-printf '%hinfo/%fn' 2>/dev/null |
xargs cat | grep -c '^inotify'
Change "$USER"
with the actual user you want info about; "`id -u`"
for the current user. Notice that the max_user_watches
is a per-user limit, not per process, or per inotify instance / file descriptor.
This will first find
all open file descriptors created by inotify_init*(2)
, and will then look into the corresponding /proc/PID/fdinfo/FD
file for the info about the watch descriptors added with inotify_add_watch(2)
to each of them (look into the proc(5)
manpage under /proc/[pid]/fdinfo/
for a description of the inotify-specific entries). The -c
option of grep
will let it print a count of all lines that match a pattern.
Note: the counter for inotify_watches
is kept just like other per-user counters in a struct ucounts
referenced from the user namespace structure -- see include/linux/user_namespace.h
; but I wasn't able to find any interface exposing those counters to userland.
add a comment |
I wish I was able to answer with something smarter, but the only way I found to count the inotify(7)
watches set by a user is this:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify
-printf '%hinfo/%fn' 2>/dev/null |
xargs cat | grep -c '^inotify'
Change "$USER"
with the actual user you want info about; "`id -u`"
for the current user. Notice that the max_user_watches
is a per-user limit, not per process, or per inotify instance / file descriptor.
This will first find
all open file descriptors created by inotify_init*(2)
, and will then look into the corresponding /proc/PID/fdinfo/FD
file for the info about the watch descriptors added with inotify_add_watch(2)
to each of them (look into the proc(5)
manpage under /proc/[pid]/fdinfo/
for a description of the inotify-specific entries). The -c
option of grep
will let it print a count of all lines that match a pattern.
Note: the counter for inotify_watches
is kept just like other per-user counters in a struct ucounts
referenced from the user namespace structure -- see include/linux/user_namespace.h
; but I wasn't able to find any interface exposing those counters to userland.
add a comment |
I wish I was able to answer with something smarter, but the only way I found to count the inotify(7)
watches set by a user is this:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify
-printf '%hinfo/%fn' 2>/dev/null |
xargs cat | grep -c '^inotify'
Change "$USER"
with the actual user you want info about; "`id -u`"
for the current user. Notice that the max_user_watches
is a per-user limit, not per process, or per inotify instance / file descriptor.
This will first find
all open file descriptors created by inotify_init*(2)
, and will then look into the corresponding /proc/PID/fdinfo/FD
file for the info about the watch descriptors added with inotify_add_watch(2)
to each of them (look into the proc(5)
manpage under /proc/[pid]/fdinfo/
for a description of the inotify-specific entries). The -c
option of grep
will let it print a count of all lines that match a pattern.
Note: the counter for inotify_watches
is kept just like other per-user counters in a struct ucounts
referenced from the user namespace structure -- see include/linux/user_namespace.h
; but I wasn't able to find any interface exposing those counters to userland.
I wish I was able to answer with something smarter, but the only way I found to count the inotify(7)
watches set by a user is this:
find /proc/*/fd -user "$USER" -lname anon_inode:inotify
-printf '%hinfo/%fn' 2>/dev/null |
xargs cat | grep -c '^inotify'
Change "$USER"
with the actual user you want info about; "`id -u`"
for the current user. Notice that the max_user_watches
is a per-user limit, not per process, or per inotify instance / file descriptor.
This will first find
all open file descriptors created by inotify_init*(2)
, and will then look into the corresponding /proc/PID/fdinfo/FD
file for the info about the watch descriptors added with inotify_add_watch(2)
to each of them (look into the proc(5)
manpage under /proc/[pid]/fdinfo/
for a description of the inotify-specific entries). The -c
option of grep
will let it print a count of all lines that match a pattern.
Note: the counter for inotify_watches
is kept just like other per-user counters in a struct ucounts
referenced from the user namespace structure -- see include/linux/user_namespace.h
; but I wasn't able to find any interface exposing those counters to userland.
edited Feb 21 at 2:33
answered Feb 20 at 20:32
mosvymosvy
7,7121530
7,7121530
add a comment |
add a comment |
I cobbled together this little script based on @mosvy's answer.
$ inotify-consumers
INOTIFY
WATCHER
COUNT PID CMD
----------------------------------------
7111 3079 node /home/carlerik/dev/nimble-frontend/node_modules/.bin/webpack --config config/webpack.dev.js
79 1541 /usr/lib/gnome-settings-daemon/gsd-xsettings
30 1664 /usr/lib/gvfs/gvfsd-trash --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
14 1630 /usr/bin/gnome-software --gapplication-service
14 1191 /lib/systemd/systemd --user
10 1371 /usr/bin/gnome-shell
9 2459 update-notifier
7 1635 nautilus-desktop
5 1191 /lib/systemd/systemd --user
2 1536 /usr/lib/gnome-settings-daemon/gsd-sound
2 1452 /usr/lib/evolution/evolution-source-registry
2 1429 ibus-daemon --xim --panel disable
2 1248 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1 1863 /usr/lib/gnome-terminal/gnome-terminal-server
1 1713 /usr/lib/evolution/evolution-addressbook-factory
1 1678 /usr/lib/ibus/ibus-engine-simple
1 1625 /usr/lib/evolution/evolution-calendar-factory
1 1560 /usr/lib/gnome-settings-daemon/gsd-housekeeping
1 1556 /usr/lib/gnome-settings-daemon/gsd-color
1 1499 /usr/lib/gvfs/gvfs-afc-volume-monitor
1 1487 /usr/lib/gnome-online-accounts/goa-identity-service
1 1480 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
1 1460 /usr/lib/gnome-online-accounts/goa-daemon
1 1440 /usr/lib/ibus/ibus-portal
1 1435 /usr/lib/ibus/ibus-x11 --kill-daemon
1 1433 /usr/lib/ibus/ibus-dconf
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1371 /usr/bin/gnome-shell
1 1352 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 12287 /home/carlerik/.sdkman/candidates/java/current/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dcl
1 1191 /lib/systemd/systemd --user
add a comment |
I cobbled together this little script based on @mosvy's answer.
$ inotify-consumers
INOTIFY
WATCHER
COUNT PID CMD
----------------------------------------
7111 3079 node /home/carlerik/dev/nimble-frontend/node_modules/.bin/webpack --config config/webpack.dev.js
79 1541 /usr/lib/gnome-settings-daemon/gsd-xsettings
30 1664 /usr/lib/gvfs/gvfsd-trash --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
14 1630 /usr/bin/gnome-software --gapplication-service
14 1191 /lib/systemd/systemd --user
10 1371 /usr/bin/gnome-shell
9 2459 update-notifier
7 1635 nautilus-desktop
5 1191 /lib/systemd/systemd --user
2 1536 /usr/lib/gnome-settings-daemon/gsd-sound
2 1452 /usr/lib/evolution/evolution-source-registry
2 1429 ibus-daemon --xim --panel disable
2 1248 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1 1863 /usr/lib/gnome-terminal/gnome-terminal-server
1 1713 /usr/lib/evolution/evolution-addressbook-factory
1 1678 /usr/lib/ibus/ibus-engine-simple
1 1625 /usr/lib/evolution/evolution-calendar-factory
1 1560 /usr/lib/gnome-settings-daemon/gsd-housekeeping
1 1556 /usr/lib/gnome-settings-daemon/gsd-color
1 1499 /usr/lib/gvfs/gvfs-afc-volume-monitor
1 1487 /usr/lib/gnome-online-accounts/goa-identity-service
1 1480 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
1 1460 /usr/lib/gnome-online-accounts/goa-daemon
1 1440 /usr/lib/ibus/ibus-portal
1 1435 /usr/lib/ibus/ibus-x11 --kill-daemon
1 1433 /usr/lib/ibus/ibus-dconf
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1371 /usr/bin/gnome-shell
1 1352 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 12287 /home/carlerik/.sdkman/candidates/java/current/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dcl
1 1191 /lib/systemd/systemd --user
add a comment |
I cobbled together this little script based on @mosvy's answer.
$ inotify-consumers
INOTIFY
WATCHER
COUNT PID CMD
----------------------------------------
7111 3079 node /home/carlerik/dev/nimble-frontend/node_modules/.bin/webpack --config config/webpack.dev.js
79 1541 /usr/lib/gnome-settings-daemon/gsd-xsettings
30 1664 /usr/lib/gvfs/gvfsd-trash --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
14 1630 /usr/bin/gnome-software --gapplication-service
14 1191 /lib/systemd/systemd --user
10 1371 /usr/bin/gnome-shell
9 2459 update-notifier
7 1635 nautilus-desktop
5 1191 /lib/systemd/systemd --user
2 1536 /usr/lib/gnome-settings-daemon/gsd-sound
2 1452 /usr/lib/evolution/evolution-source-registry
2 1429 ibus-daemon --xim --panel disable
2 1248 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1 1863 /usr/lib/gnome-terminal/gnome-terminal-server
1 1713 /usr/lib/evolution/evolution-addressbook-factory
1 1678 /usr/lib/ibus/ibus-engine-simple
1 1625 /usr/lib/evolution/evolution-calendar-factory
1 1560 /usr/lib/gnome-settings-daemon/gsd-housekeeping
1 1556 /usr/lib/gnome-settings-daemon/gsd-color
1 1499 /usr/lib/gvfs/gvfs-afc-volume-monitor
1 1487 /usr/lib/gnome-online-accounts/goa-identity-service
1 1480 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
1 1460 /usr/lib/gnome-online-accounts/goa-daemon
1 1440 /usr/lib/ibus/ibus-portal
1 1435 /usr/lib/ibus/ibus-x11 --kill-daemon
1 1433 /usr/lib/ibus/ibus-dconf
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1371 /usr/bin/gnome-shell
1 1352 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 12287 /home/carlerik/.sdkman/candidates/java/current/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dcl
1 1191 /lib/systemd/systemd --user
I cobbled together this little script based on @mosvy's answer.
$ inotify-consumers
INOTIFY
WATCHER
COUNT PID CMD
----------------------------------------
7111 3079 node /home/carlerik/dev/nimble-frontend/node_modules/.bin/webpack --config config/webpack.dev.js
79 1541 /usr/lib/gnome-settings-daemon/gsd-xsettings
30 1664 /usr/lib/gvfs/gvfsd-trash --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
14 1630 /usr/bin/gnome-software --gapplication-service
14 1191 /lib/systemd/systemd --user
10 1371 /usr/bin/gnome-shell
9 2459 update-notifier
7 1635 nautilus-desktop
5 1191 /lib/systemd/systemd --user
2 1536 /usr/lib/gnome-settings-daemon/gsd-sound
2 1452 /usr/lib/evolution/evolution-source-registry
2 1429 ibus-daemon --xim --panel disable
2 1248 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1 1863 /usr/lib/gnome-terminal/gnome-terminal-server
1 1713 /usr/lib/evolution/evolution-addressbook-factory
1 1678 /usr/lib/ibus/ibus-engine-simple
1 1625 /usr/lib/evolution/evolution-calendar-factory
1 1560 /usr/lib/gnome-settings-daemon/gsd-housekeeping
1 1556 /usr/lib/gnome-settings-daemon/gsd-color
1 1499 /usr/lib/gvfs/gvfs-afc-volume-monitor
1 1487 /usr/lib/gnome-online-accounts/goa-identity-service
1 1480 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
1 1460 /usr/lib/gnome-online-accounts/goa-daemon
1 1440 /usr/lib/ibus/ibus-portal
1 1435 /usr/lib/ibus/ibus-x11 --kill-daemon
1 1433 /usr/lib/ibus/ibus-dconf
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1410 /usr/bin/pulseaudio --start --log-target=syslog
1 1371 /usr/bin/gnome-shell
1 1352 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 1254 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
1 12287 /home/carlerik/.sdkman/candidates/java/current/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dcl
1 1191 /lib/systemd/systemd --user
answered 2 days ago
oligofrenoligofren
1408
1408
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498393%2fhow-to-get-the-number-of-inotify-watches-in-use%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown