So I have this script running, using inotifywait. One server puts images into a NFS folder on the host server at /var/nfs/device_images. (chmod is 777 on working folders) The host server then moves it into a working directory of a python script.
inotifywait -m /var/nfs/device_images -e create -e moved_to | while read path action file; do cp /var/nfs/drvie_images/$file /home/samuel/programname/images/$file; done
It works, kinda. The file itself transfers, but it's corrupt. It seems inotifywait tries to send the photo before it's totally transferred? Anyone have a solution?
create
event would be triggered as soon as a file gets created even before it gets fully written, making it look like the images are corrupt
One way to solve this is by making inotifywait
to listen for only move
event and forcing the server that populates /var/nfs/device_images
to create the files in a temp directory and move that to /var/nfs/device_images
on completion.
You can specify temp
directory for most utilities that are used to grab the files like rsync
/ wget