[Gloucs] "Is the file completed" in bash
Paul Broadhead
lug at twinmoons.clara.co.uk
Wed Jul 13 11:13:38 BST 2005
Glyn Davies <glynd at walmore.com> wrote:
> What's the best way in a script of determining that a file has been
> finished being written to before going on to process it? I'm writing a
> script to rename user backup files to something more meaningful but
> obviously, I don't want to rename a file part way through its
> creation.
Hey a bash question. Unfortunately I don't know the answer ;-(
However, the command stat may help; you can get information about
modification times, file sizes etc. You save the output of "stat
thefile | grep ^Modify:" then compare this with the output a few seconds
later, proceeding if the stat output is the same.
Alternatively, the find command also has filters for modification times.
The following command only finds files, with the .gz extension, that
have not been changed in the last minute:
find . -name "*.gz" ! -cmin 1 -print
Regards,
Paul
More information about the gloucs
mailing list