inotify

something like INotifyCollectionChanged fires on xml file changed

隐身守侯 提交于 2019-12-13 21:08:18
问题 It's possible to implement INotifyCollectionChanged or other interface like IObservable to enable to bind filtered data from xml file on this file changed ? I see examples with properties or collection, but what with files changes ? I have that code to filter and bind xml data to list box: XmlDocument channelsDoc = new XmlDocument(); channelsDoc.Load("RssChannels.xml"); XmlNodeList channelsList = channelsDoc.GetElementsByTagName("channel"); this.RssChannelsListBox.DataContext = channelsList;

Get notified about the change in raw data in hard disk sector - File change notification

江枫思渺然 提交于 2019-12-13 19:53:58
问题 I'm trying to make a software that backups my entire hard drive. I've managed to write a code for reading the raw data from hard disk sectors. However, i want to have incremental backups. For that i need to know the changed made to OS settings, file changes, everything. My question is - Using FileSystemWatcher and Inotify, will i be able to know every change made to every sector in the hard drive ? (OS settings etc) I'm coding it in C++ for linux and windows. (Saw this question on

【集群实战】共享存储实时备份(解决nfs共享存储的单点问题)

断了今生、忘了曾经 提交于 2019-12-13 16:10:59
1. nfs存储的单点问题 如果nfs服务器宕机了,则所有的nfs客户机都会受到影响。一旦宕机,会丢失部分用户的数据。为了解决单点问题,需要实现共享存储的实时备份,即:将nfs服务端共享目录下的数据实时备份到备份服务器(或其它存储设备),以保证数据的完整性。 2. NFS共享数据的实时同步推送备份 公司有两台web服务器一直在对外提供服务,但随着业务的发展用户越来越多,网站的功能也越来越强大,各种图片,视频等占用硬盘空间越来越大。 于是,领导将web服务器的数据直接存储到NFS服务器上作为存储使用;并且为了防止NFS服务器发生单点故障,领导希望将web服务器存储的内容实时同步到Rsync备份服务器上。现在由你来计划完成领导的需求。 具体要求如下: NFS服务器的要求如下: 服务器的共享目录名为/data目录; 权限要求只能内网网段访问且可读可写,时时同步; 为了方便管理人员管理,需要指定NFS虚拟账户为zuma,uid=888,gid=888 所有访问者的身份都压缩为最低身份 将/data目录里的内容同步时时推送到备份服务器的/data目录里(inotify+rsync) web服务器将NFS共享目录统一挂载到/var/html/www目录下 思路: 1. NFS存储服务器和Rsync备份服务器,Rsync服务器部署运行rsync --daemon服务

Why can't I monitor /proc using the inotify C API? Is it special?

徘徊边缘 提交于 2019-12-13 05:18:31
问题 I've written a few lines of C code using the inotify API. When I monitor for IN_CREATE and IN_DELETE for /tmp it works no problem. I can detect when I add or delete folders in /tmp. When I change the monitored folder to /proc, I do not get notified when a new directory is created in /proc due to a process launch. I assume this is because /proc is special in some way. Can anyone explain why this is the case or what I might do to allow inotify to watch that folder? Thanks. 回答1: The stuff in

Using inotify on a busy directory

泄露秘密 提交于 2019-12-13 03:39:22
问题 I am using inotify on a busy directory(files keep on getting generated). I wish to catch the IN_CLOSE_WRITE events for all of them. So I tried something like this. fd = inotify_init(); inotify_add_watch(fd, DIR_PATH, IN_CLOSE_WRITE); while(1) { len = read(fd, buff, INOTIFY_EVENT_SIZE); if (len < 0) { PRINT_ERROR("Read failed. Keep watching.\n"); continue; } /* Process the event */ } This method is failing to catch the events that are generated while I am processing the event of first read. I

whats the correct way to loop this

99封情书 提交于 2019-12-12 06:58:00
问题 I have a script where inotifywait is piped into a while loop that executes the following logic. cp "$S3"/2/post2.png "$S3"; mv "$S3"/1/post1.png "$S3"/2/post2.png; cp "$S3"/3/post3.png "$S3"; mv "S3"/post2.png "$S3"/3/post3.png; so forth and so on..... then at the end of the script... mv "$dir"/$file "$S3"/1/post1.png That line represents a fresh post, the above is the rotation of older post. I can can hand code the iterations all the way down to 100+, but I would like to program more

inotify script runs twice?

混江龙づ霸主 提交于 2019-12-12 04:33:25
问题 I'm using inotify-tools ( inotifywait ) on CentOS 7 to execute a php script on every file creation. When I run the following script: #!/bin/sh MONITORDIR="/path/to/some/dir" inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE do php /path/to/myscript.php ${NEWFILE} done I can see there are 2 processes: # ps -x | grep mybash.sh 27723 pts/4 S+ 0:00 /bin/sh /path/to/mybash.sh 27725 pts/4 S+ 0:00 /bin/sh /path/to/mybash.sh 28031 pts/3 S+ 0:00 grep --color=auto mybash

inotify missing events

烈酒焚心 提交于 2019-12-11 06:44:18
问题 I want to monitor USB-Keys on my system. I know they are always mounted in /media so I use inotify to monitor /media. Some USB Keys create a folder (e.g. sda) when plugged which stays until they are unplugged, some create a folder (e.g. sda), delete it imediately and create a new one (e.g. sda1). That's due to the partitions on the key. However, sometimes inotify catches only the events for creation and deletion of the first folder, but misses the creation of the second. When I manually check

`entr`: How is update ID'd? noatime troubles? &, why -r not work with -d?

こ雲淡風輕ζ 提交于 2019-12-11 05:24:46
问题 I have a script regularly appending to a log file. When I use entr (discovered here) to monitor that log file, and I then touch the log, everything works fine, but when the script appends to the file, entr fails. This may be because I have noatime set in my fstab - but that only stops the updating of the access time not the modify time, so this confuses me. I've checked and while atime is not updating, ctime ( ls -lc ) definitely is. Could entr really be depending on atime? I use noatime

The read method on the inotify descriptor does not return

一笑奈何 提交于 2019-12-11 04:23:51
问题 My program monitors changes on files using inotify(7) fd = inotify_init(); inotify_add_watch (fd, "./test.txt", IN_ALL_EVENTS); //start forever monitor while(true){ ssize_t len, i = 0; char action[81+FILENAME_MAX] = {0}; char buff[BUFF_SIZE] = {0}; len = read (fd, buff, BUFF_SIZE); while (i < len) { //process event i += sizeof(struct inotify_event) + pevent->len; } } The problem is that the read function only return several times for the firt changes in the monitor file (ACCESS, OPEN, MODIFY