LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script file access check? (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-file-access-check-849573/)

viperuk 12-10-2010 08:09 PM

bash script file access check?
 
Hi all

I have been using linux for a bit of time but would still class myself as a noobie. I dont know excatly what I am looking for but I can best describe it in a sanario.

I have started creating bash scripts which are looped indefinetly which checks a folder for files to process. my problem is, is there any way to check if the file is complete, as if the file is large and is being coppied from a different volume the file may still be copying or if the file is being uploaded by a user over samba/nfs, and if the file is still copying the process will most likely fail. if anyone has any ideas on how to resolve my problem I would be greatful

viperuk

catkin 12-10-2010 08:20 PM

The most robust method is, if the file is being copied, the copier copies it under a special name and renames when copying is complete. For example foo might be copied to foo.part which would be renamed as foo.

If that is not feasible an alternative is to use the last modification time of the file and not copy files with last modification times less than <whatever> time ago. The stat and date commands would be useful.


All times are GMT -5. The time now is 11:41 AM.