I'm trying to do consistent writes to a NFS folder that can go offline for maybe 30 seconds while i'm writing in it.

Why does the NFS server go down? How can you avoid that? Is it a planned downtime? If so, can you arrange to be notified automatically before and after the downtime?

I think you should not try to work around such problems in your application. Think about different solutions.

rsync could be useful: You write to a local file, and tell rsync to sync it to the storage server. If the connection breaks, you simply restart rsync until the entire file is transfered.

Also check the NFS mount options: The NFS client code should be able to block your write attempt until the NFS server goes online again. This will make your programm stall for that time, but should do no other harm.

Consider using a simple ssh connection (hoping that that won't go down as often as NFS):

#!/usr/bin/perl use strict; use warnings; open my $out,'| ssh server cat ">>" /tmp/log.txt' or die "open failed: + $!"; print $out "hello world\n" for 1..10; close $out;

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Delaying NFS writes by afoken
in thread Delaying NFS writes by ZlR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.