Here is the situation. Script1, written in Python, generates files to its local directory. When file is "ready", script1 moves it to ready dir. Script2 monitors ready dir and moves files from it to remote server, for example. So, the question is: how to ensure that script2 move file from ready dir only then script1 finished moving it?
The only decision I can suggest is adding some prefix while moving to ready dir and renaming file after moving is done. Script2 should only move files without prefix. Is this decision good enough for my situation?
UPD. I am using Debian 6 minimal. I'm not using script1 to copy files to remote server because of security reasons.
You could add an event to the incron table to 'watch' the /ready folder.
To view your incron table from command line :
incrontab -e
Likely it is empty, you could add an event as such :
/folder/path/to/ready IN_CLOSE_WRITE /path/to/the/second/script/Script2.sh $#
Note, I'm referencing a shell script, not the python file directly in this event. INCRON passes the filename as the first argument to the script ( $1 ). This line simply waits for an IN_CLOSE_WRITE event to occur in the /folder/path/to/ready, which would be triggered when Script1 finishes moving the file over to this folder.
You can then create Script2.sh to call your python script with any other dependencies ( like activating a virtual environment for example ).
A simple shell script might look like :
python script2.py $1
Then just make sure your second script handles the incoming file as you intend - moving it to the remote server.
For more info on INCRON see http://linux.die.net/man/5/incrontab