Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

how to know when a file is finish writing

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
nngdemi
Asked:
nngdemi
1 Solution
 
ozoCommented:
How does your software generate the files?
0
 
tel2Commented:
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
 
purkar_sanCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
nngdemiAuthor Commented:
This question has a deletion request Pending
0
 
tel2Commented:
This question no longer is pending deletion
0
 
tel2Commented:
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
 
nngdemiAuthor Commented:
thanks tel2,
   I no longer need to do this
anymore.

Thanks again for the help.
0
 
tel2Commented:
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
 
GP1628Commented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now