Please present the problem, as well as your suggested solution.
If you are trying to avoid copying a file while a program it still writing that file, consider using the unix fuser command to determine that fact.
Conventional system design would transfer files into a relay directory under a temporary filename, and rename each file after a successful transfer.
Also, why do you need to avoid copying these files? Are these files being uploaded by FTP or the like?
-These files generated from other programs my script will run every 5 minutes through crontab.
I just want to check while copy these files the original script who writes these files on source should not be writing in the file while my script is running.
Once the copy finished I will delete this file.
As long as the destination is on the same filesystem, moving a file that's being written to is completely safe. Nothing impacts already-open file descriptors -- all you're doing is changing directory entries.
Otherwise, the cron entries responsible for creating the file should really be responsible for moving it, too. They actually know when they're done, no wild guess of two minutes is necessary.
No I can't move the file. because in some cases I need to copy same file in 2 different directories.
So once I copy the file on destination I will redirect source_path in a tmp file. once completed copying all the files I will again do a loop on my tmp file and delete all files which copied.
The cron entries responsible for creating the file should really be responsible for moving it, too. They actually know when they're done, no wild guess of two minutes is necessary.
Please post what Operating System and version you have. We need to know whether your find command has the -mmin switch of whether it just has the usual accuracy of 24 hours.