Hi Yaman,
Just out of the top of my head coz I just woke up... Why not use mv, coz mv is atomic and any process that still has access to the file would still be able to write to the old file until you restart that process. --- On Tue, 5/12/09, Yaman Saqqa <[email protected]> wrote: > From: Yaman Saqqa <[email protected]> > Subject: [JoLUG-General] Question on cp > To: [email protected] > Date: Tuesday, May 12, 2009, 3:13 PM > Hello Luggers, > > A quick question. > > Let's say I wanna rotate a log file upon reaching a > certain size and the file name is time dependent. logrotate > configuration wildcards will not help, so I'm writing a > script to do it, my questions is, as per the pseudo below > > > > every x time > check file size > if size > y > cp oldfile oldfile-1 && echo > oldfile # > (copy-truncate) because processes have open fd's with > oldfile > fi > > If the file size is large, cp WILL take some time and > CONCURRENTLY data is still being written to the oldfile. > Will cp cater to every byte written to the oldfile up > until the micro-second "&& echo kicks in"? > Or will there be data loss? > > > > Thanks! > > -- > abulyomon > > www.KiLLTHeUPLiNK.com > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ ### Jordan Linux Users Group ### http://Jolug.org/ http://groups.google.com/group/Jolug ### Ubuntu Jordan LoCo Team ### https://wiki.ubuntu.com/JordanTeam http://lists.ubuntu.com/ubuntu-jo ### Ojuba Linux ### http://ojuba.org/ ### Jordan PHP ### http://groups.google.com/group/JoPHP -~----------~----~----~----~------~----~------~--~---

