I have a video encoding script that I would like to run as soon as a file is moved into a specific directory.
If I use something like inotify, how do I ensure that the file isn't encoded until it is done moving?
I've considered doing something like:
- Copy (rsync) file into a temporary directory.
- Once finished, move (simple 'mv') into the encode directory.
- Have my script monitor the encode directory.
However, how do I get step #2 to work properly and only run once #1 is complete?
I am using Ubuntu Server 11.10 and I'd like to use bash, but I could be persuaded to use Python if that'd simplify issues.
I am not "downloading" files into this directory, per se; rather I will be using rsync the vast majority of the time.
Additionally, this Ubuntu Server is running on a VM.
I have my main file storage mounted via NFS from a FreeBSD server.