从手册页inotifywait
:
EVENTS
...
unmount
The filesystem on which a watched file or directory resides was unmounted.
After this event the file or directory is no longer being watched. Note
that this event can occur even if it is not explicitly being listened to.
我正在努力让它发挥作用,但没有成功。卸载监视目录后,程序继续运行,并且不打印任何内容。
准备测试:
cd /tmp/
fallocate -l500M test.img
mkdir -p /media/test
losetup -f test.img
mkfs.ext4 /dev/loop0
mount /dev/loop0 /media/test
inotifywait -m /media/test &
inotifywait -m /media &
测试其他事件是否有效:
[root@basinsrv tmp]# touch /media/test/xxx
/media/test/ CREATE xxx
/media/test/ OPEN xxx
/media/test/ ATTRIB xxx
/media/test/ CLOSE_WRITE,CLOSE xxx
[root@basinsrv tmp]#
卸载:
[root@basinsrv tmp]# umount /media/test
[root@basinsrv tmp]#
我的系统:
[root@basinsrv tmp]# uname -a
Linux basinsrv 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@basinsrv tmp]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)