(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



file busy


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From - Wed Nov  8 06:23:41 2000
Path: news.randori.com!newsfeeder.randori.com!europa.netcrusader.net!63.211.125.72!cyclone2.usenetserver.com!news-out.usenetserver.com!cyclone1.usenetserver.com!e420r-sjo3.usenetserver.com.POSTED!not-for-mail
Newsgroups: comp.unix.sco.misc
Subject: Re: knowing when a file is busy?
References: <u71ywnqw90.fsf@benburb.tangent.com> 
Organization: The Armory
X-Newsreader: trn 4.0-test69 (20 September 1998)
From: spcecdt@deeptht.armory.com. (John DuBois)
Lines: 18
Message-ID: <dK4O5.386$84.40247@e420r-sjo3.usenetserver.com> 
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
X-Complaints-To: support@usenetserver.com
NNTP-Posting-Date: Tue, 07 Nov 2000 23:35:21 EST
Date: Wed, 08 Nov 2000 04:35:21 GMT
Xref: news.randori.com comp.unix.sco.misc:68452
X-Mozilla-Status: 8011
X-Mozilla-Status2: 00000000

In article <u71ywnqw90.fsf@benburb.tangent.com>,
joe mc cool  <joe@benburb.demon.co.uk> wrote:
>How can I be sure that the application has finished writing to the end 
>of the file before I grab it ?  Cron would check every minute, say,
>and if the file existed it would send it to the printer and then erase 
>it.  Of course I could rename the file before printing it.  But does
>that guarantee that I won't loose data ?  What is the safe approach ?

You need a combination of approaches.  First, rename the file; then, use fuser
or lsof in a loop to check whether the file is open.  Open file descriptors
won't be affected by the renaming, so if anything is writing to the file it
will continue writing.  Once the file is no longer open, print it and remove it
(arrange for both at once with lp -R).  Note that you need to be root to use
fuser.



        John
-- 
John DuBois  spcecdt@armory.com.  KC6QKZ/AE  http://www.armory.com./~spcecdt/





Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar


LOD Communications, Inc.


/Bofcusm/718.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.



More:
       - OSR5
       - Bofcusm


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress