Modified files on the cloud by inotifywait

S

Sandro kensan

Guest
Hi,
i would like to copy on the cloud some selected files when modified. The script is this:
Code:
while : do
  file = $(inotifywait --fromfile /tmp/list.txt --event modify --format "%w")
  cp -f "$file" $HOME/cloud
done

The problem is that inotifywait don't print the files that has been modified. It is a bug? It is my mistake?

Other example:
Code:
$ inotifywait file1.txt file2.txt --event modify --format %w
print only
Code:
Setting up watches.
Watches established.
and exits when event occurs.
 


inotifywait waits for changes to files, it does not show files that have been
changed.


inotifywait efficiently waits for changes to files using Linux's
inotify(7)
interface. It is suitable for waiting for changes to files from shell
scripts. It can either exit once an event occurs, or continually
execute and output events as they occur.


http://linux.die.net/man/1/inotifywait

an example:A short shell script to efficiently wait for httpd-related log messages and do something appropriate.
Code:
#!/bin/sh
while inotifywait -e modify /var/log/messages; do
  if tail -n1 /var/log/messages | grep httpd; then
    kdialog --msgbox "Apache needs love!"
  fi
done
 
Tanks ryanvade for the answer. So I think my only option is to modify the source code of inotifywait or to use other inotify in other language like PHP or Phyton: do you agree?
 
I have found the solution:
Code:
while true; do file=$( inotifywait -q --fromfile /tmp/lista.txt --format
'%w' --event DELETE_SELF,MODIFY ); cp -f "$file" "Cloud"/; done

See this post:

stackoverflow com/questions/2754954/inotify-delete-self-when-modifying-and-saving-a-file

Kwrite and other editors don't modify the files thy deleted the files (moove, mv). nano modify the files. Also inotifywait died when the files that is monitor is deleted so no output is send.
 

Members online


Top