Maintaining file currency

I have a common data folder with files like x* which is accessed by 3 unix servers.

Now each server will try to pick one file form this folder and move it to its local folder.

How to maintain file concurrency in this case?I dont want the same file to be accessed by more than one process.

Since no one is trying to answer, I will give it a try to see if it can fit your requirement

Assuming each server is consuming the files one at a time, we may be able to run 'cksum' on the files and take the modular to determine if the file is meant for a particular server to process.

Suppose you have 3 servers (server1, server2, server3). server1 will consume any file cksum%3==0, server2 will consum any file cksum%3==1, etc

For server1, this is the code to pick up the first file to process

ls -1 x* 2>/dev/null | xargs cksum | awk '$1%3==0{print $3;exit(0)}'

If you still want to use some form of locking mechanism, try 'flock' (managing lock from shell script)

We need to know a lot more about the environment (Operating Systems, Shell etc.) and the process.