I am using a local website which downloads files to my server. Using an Inotify daemon I'm listening for file changes in a specific folder (the one I am downloading to) and executing a script which moves those files into another folder using rsync. However my problem here is that rsync moves the files before they are completely downloaded so they are at 0KB. I used mv before, and mv somehow managed to wait until the download is completed before moving, but I needed to use rsync because mv won't write to existing, non-empty folders.
Any ideas?
Here is my script which executes on inotify create:
#!/bin/sh
cd the_folder_which_is_watched_by_inotify
rsync -vh * /where_the_files_are_moved_to
echo "Files have been moved"