When monitoring active application logs or system events in Linux using the follow flag (tail -f or tail -F), you may observe the terminal output pausing briefly and printing the diagnostic warning: “tail: inotify cannot be used, reverting to polling: No space left on device” or “tail: inotify cannot be used, reverting to polling: Function not implemented”. While the tail command continues to function by periodically polling the file on disk, falling back to polling increases CPU utilization, introduces noticeable lag in log output delivery, and can fail to capture rapid log rotations.
Why tail Reverts from inotify to Polling
Under Linux, the GNU tail utility uses the inotify kernel subsystem to receive immediate asynchronous notifications whenever an inspected file descriptor is written to or modified. Tail falls back to crude polling for two distinct architectural reasons:
- Exceeded inotify Watch Limits: The system has reached its configured
fs.inotify.max_user_watchesorfs.inotify.max_user_instancesthreshold. Modern development tools (such as VS Code, Docker, Webpack, and IDE file watchers) consume thousands of inotify watches simultaneously, exhausting the global allocation table. - Unsupported File Systems: The monitored file resides on a remote or virtual filesystem that does not implement the kernel inotify interface. Common examples include Network File System (NFS), Server Message Block (SMB/CIFS) mounts, and certain Docker/Kubernetes overlay volume mounts.
Step 1: Check Current inotify System Watch Limits
Before adjusting kernel parameters, inspect your current usage and limits to determine if watch exhaustion is the culprit.
- Open your Linux terminal.
- Query the current maximum watch limit by executing:
(Default values on older systems may be as low ascat /proc/sys/fs/inotify/max_user_watches8192.) - Query the maximum instance limit:
cat /proc/sys/fs/inotify/max_user_instances - Identify which processes are consuming the largest number of watch instances:
find /proc/*/fd/* -type l -lname 'anon_inode:inotify' 2>/dev/null | cut -d/ -f3 | sort | uniq -c | sort -nr | head -n 10
Step 2: Increase inotify Watches Temporarily via sysctl
If you need to restore fast event notification immediately without rebooting your Linux server or workstation, raise the watch limit dynamically.
- Increase the maximum user watches to
524288(512K) and instances to1024:sudo sysctl -w fs.inotify.max_user_watches=524288sudo sysctl -w fs.inotify.max_user_instances=1024 - Verify that the new values took effect:
sudo sysctl -p - Run your
tail -f /path/to/logfile.logcommand again. The inotify warning will disappear, and logs will stream in real time.
Step 3: Make inotify Limits Persistent Across Reboots
Changes made dynamically with sysctl -w revert upon the next system restart. To persist these allocations, save them to the sysctl configuration directory.
- Create or edit a custom configuration drop-in file:
sudo nano /etc/sysctl.d/60-inotify.conf - Add the following two lines:
fs.inotify.max_user_watches = 524288 fs.inotify.max_user_instances = 1024 - Save the file and exit the editor (in nano, press Ctrl + O, Enter, then Ctrl + X).
- Apply the permanent configuration immediately:
sudo sysctl --system
Step 4: Handling NFS, CIFS, and Docker Network Mounts
If the file you are tailing resides on a network share mounted via NFS or Samba, the underlying storage protocol cannot send kernel inotify events to your local machine. In this scenario, reverting to polling is normal and unavoidable.
- To suppress the warning message cleanly when you know the file is on a network mount, pass the explicit polling interval switch to tail:
(The triple dashtail ---disable-inotify -s 1 -f /mnt/nfs/server.log---disable-inotifyinstructs GNU tail to use polling directly without querying inotify, silencing the warning completely.) - The
-s 1flag configures tail to sleep for 1 second between polls, conserving network bandwidth and CPU cycles while still updating frequently.