We help IT Professionals succeed at work.

how to know when a file is finish writing

nngdemi
nngdemi asked
on
311 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
Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
How does your software generate the files?
CERTIFIED EXPERT

Commented:
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.
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.

Author

Commented:
This question has a deletion request Pending
CERTIFIED EXPERT

Commented:
This question no longer is pending deletion
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks tel2,
   I no longer need to do this
anymore.

Thanks again for the help.
CERTIFIED EXPERT

Commented:
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?

Commented:
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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.