Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-10-2010, 09:09 PM   #1
LQ Newbie
Registered: Jan 2008
Location: UK
Distribution: Debian
Posts: 9

Rep: Reputation: 0
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

Old 12-10-2010, 09:20 PM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
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.


bash scripting

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script file access question KBriggs Linux - Newbie 2 08-10-2009 02:54 PM
bash script to check mount is ok procfs Programming 2 01-17-2007 07:19 PM
How do I check for directory in bash script? nadavvin Programming 1 09-13-2006 05:03 PM
How to check the bash script syntax? mesh2005 Linux - General 2 04-23-2006 09:22 AM
how to have bash script check whether it's a x session? bkeeper Linux - Newbie 9 02-21-2006 07:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration