03-01-2012
How to copy a binary file while the file is being written to by another process
Hello,
Can I copy a binary file while the file is being written to by another process?
Another process (program) “P1” creates and opens (for writing) binary file “ABC” on local disk. Process P1 continuously write into ABC file every couple of seconds, adding 512-byte blocks of data. ABC file usually grows to the size of 20-30 MB.
I need to make a copy (replica) of ABC file every one hour, while process P1 is still active. My copy action must not disturb process P1 and no data can be lost (not written) into ABC file because of my copy action. It is ok if my action causes a short delay in P1 writing, but data must not be lost. It is ok if my copy of ABC file misses the latest blocks of data from ABC file. If I can safely make a copy of ABC file which will be a snapshot of ABC file from 5 minutes ago, that is ok for me.
Can you please help me with the description of steps that I need to do in my program or script?
Is there a way to open a file for read-only, but in a way that UNIX would guarantee that my reading program will not disturb the other writing program P1?
I'm working on AIX server.
Thank you,
Milan
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello,
Which command in unix can tell whether a file is being used/written by another process.
e.g. If one process is copying a very big file in some directory and there is another cronjob process which checks for a new file and in this directory and process the file. I want to check, if the... (4 Replies)
Discussion started by: sanjay92
4 Replies
2. Shell Programming and Scripting
Hello All
I am attempting to write a shell script (bourne shell script) which will copy a tar'd and compressed file from a directory to a staging area but will not know whether the file is still open for write since files are being ftp's to my site at random times during the day.
Once I am... (14 Replies)
Discussion started by: kanejm
14 Replies
3. Solaris
Hi,
I have two Solaris machines.
1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500
2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60
I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies
4. Shell Programming and Scripting
Hi experts,
I have a requirement wherein a user is uploading a file to the Landing directory on one of our Linux servers. A cron job is scheduled to run after every 5 minutes which will pick up the files from the source (Landing) dir and copy to the target dir, and once successfully copied to... (4 Replies)
Discussion started by: adi_2_chaos
4 Replies
5. Shell Programming and Scripting
my user copy large files, and it's take 10min for file to be copied to the server (/tmp/user/ files/), if in the meantime start my scheduled script, then it will copy a part of some file to server1
my idea is to check the file size twice in a short period (1-2 seconds) of time, then compare, if... (5 Replies)
Discussion started by: waso
5 Replies
6. UNIX for Dummies Questions & Answers
This is my input file like this
03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/
49,+00000000000416920,00002/
03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/
88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/
88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies
7. Shell Programming and Scripting
I would like to know
Is it possible to get a notification as pop-up in linux
when a folder with extension '.aqs' written
a popup should come
as " The folder has been written "
Thank you in advance (5 Replies)
Discussion started by: bal_nair
5 Replies
8. Shell Programming and Scripting
HI All,
Actually i have file xxx.txt where entry is like as follow.
prepaid_123.txt
prepaid_134.txt
prepaid_156.txt
So my problem is i want to find all fille except these three file in current directly of same format prepaid_xxx.txt
Can you please help
Thanks in Adcance (7 Replies)
Discussion started by: sujit_kashyap
7 Replies
9. Shell Programming and Scripting
Hello *nix specialists,
Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies
10. Shell Programming and Scripting
Hi ,
Is there any script to copy a files (weblogic bianary + silent.xml ) from one server (linux) to another servers and then execute the copy file.
We want to copy a file on multiple servers and run the installation.
Thanks (1 Reply)
Discussion started by: Nawrajesh
1 Replies
LEARN ABOUT CENTOS
funflush
funflush(3) SAORD Documentation funflush(3)
NAME
FunFlush - flush data to output file
SYNOPSIS
#include <funtools.h>
void FunFlush(Fun fun, char *plist)
DESCRIPTION
The FunFlush routine will flush data to a FITS output file. In particular, it can be called after all rows have been written (using the
FunTableRowPut() routine) in order to add the null padding that is required to complete a FITS block. It also should be called after com-
pletely writing an image using FunImagePut() or after writing the final row of an image using FunTableRowPut().
The plist (i.e., parameter list) argument is a string containing one or more comma-delimited keyword=value parameters. If the plist string
contains the parameter "copy=remainder" and the file was opened with a reference file, which, in turn, was opened for extension copying
(i.e. the input FunOpen() mode also was "c" or "C"), then FunFlush also will copy the remainder of the FITS extensions from the input ref-
erence file to the output file. This normally would be done only at the end of processing.
Note that FunFlush() is called with "copy=remainder" in the mode string by FunClose(). This means that if you close the output file before
the reference input file, it is not necessary to call FunFlush() explicitly, unless you are writing more than one extension. See the
evmerge example code. However, it is safe to call FunFlush() more than once without fear of re-writing either the padding or the copied
extensions.
In addition, if FunFlush() is called on an output file with the plist set to "copy=reference" and if the file was opened with a reference
file, the reference extension is written to the output file. This mechanism provides a simple way to copy input extensions to an output
file without processing the former. For example, in the code fragment below, an input extension is set to be the reference file for a
newly opened output extension. If that reference extension is not a binary table, it is written to the output file:
/* process each input extension in turn */
for(ext=0; ;ext++){
/* get new extension name */
sprintf(tbuf, "%s[%d]", argv[1], ext);
/* open input extension -- if we cannot open it, we are done */
if( !(ifun=FunOpen(tbuf, "r", NULL)) )
break;
/* make the new extension the reference handle for the output file */
FunInfoPut(ofun, FUN_IFUN, &ifun, 0);
/* if its not a binary table, just write it out */
if( !(s=FunParamGets(ifun, "XTENSION", 0, NULL, &got)) ||
strcmp(s, "BINTABLE")){
if( s ) free(s);
FunFlush(ofun, "copy=reference");
FunClose(ifun);
continue;
}
else{
/* process binary table */
....
}
}
SEE ALSO
See funtools(7) for a list of Funtools help pages
version 1.4.2 January 2, 2008 funflush(3)