Solved

how to know when a file is finish writing

Posted on 2000-02-15
9
255 Views
Last Modified: 2010-04-21
I have a software that generate files
in /disk1 directory;  I want to write
a shell script which
to move all complete files from
/disk1 to /disk2;  don't move the file
that is still growing, or in the process of creating.


thanks
0
Comment
Question by:nngdemi
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2525235
How does your software generate the files?
0
 
LVL 11

Expert Comment

by:tel2
ID: 2525606
nngdemi,

If you issue the command:
  fuser <filename>
and it DOESN'T list any processes numbers next to the filename, then the file SHOULD be finished growing (as long as your software keeps the file "open" all the time until it's finised writing to it, which would usually be the case).

If you want help to automate the above as a cron job, then give us some example directory and file names and we might write a script for you.
0
 

Expert Comment

by:purkar_san
ID: 2526322
Hi ozo
How you come know that, your software has released that file and you want to move to other area? Moving file from one area to another area is not big stuff. As suggested by tel2, that can done by cron. But for that you have to give some idea about, at what condition you want to move file.  On size basis or on creation date or something else. Some logic must be there.
0
 

Author Comment

by:nngdemi
ID: 2528034
This question has a deletion request Pending
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 11

Expert Comment

by:tel2
ID: 2528633
This question no longer is pending deletion
0
 
LVL 11

Accepted Solution

by:
tel2 earned 100 total points
ID: 2528634
nngdemi,

I see you trying to delete this question.
Any problems with the following solution, which I am posting again, as an Answer this time?

If you issue the command:
  fuser <filename>
and it DOESN'T list any processes numbers next to the filename, then the file SHOULD be finished growing (as long as your software keeps the file "open" all the time until it's finised writing to it, which would usually be the case).

If you want help to automate the above as a cron job, then give us some example directory and file names and we might write a script for you.
 
0
 

Author Comment

by:nngdemi
ID: 2532650
thanks tel2,
   I no longer need to do this
anymore.

Thanks again for the help.
0
 
LVL 11

Expert Comment

by:tel2
ID: 2532832
nngdemi,

OK, but you asked the question, I went to the trouble of answering it less than 4 hours later, so I think, whether you still want it or not, you should either accept my answer and give me the points, or reject it and tell me what's wrong with it.

It's like you asked for a job to be done and offered a price, and then someone did the job and you didn't pay.

Otherwise, everyone could just post questions, and when they get the answer they want they could just say they don't it anymore.  Pretty soon, no one would bother answering questions.

Sound fair?  What do you think?
0
 
LVL 2

Expert Comment

by:GP1628
ID: 2555073
for others................ old military answer. easy to use in any program on any machine.

Use a GO file.
have the program creating the files create one more file at the end. Something like GO.txt

Have the transfer program watch or test for GO.txt and when it appears it can begin downloading the other files which will all be done.

Even if it reaches GO.txt while it is still being written (unlikely since it would be like a 1byte file) it wouldnt matter since its a junk file that you dont care about.

Delete GO.txt when you are done and put the script back to watching for another GO.txt to appear

Gandalf
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now