zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sweth Chandramouli <sweth@astaroth.nit.gwu.edu>,
	ZSH Users <zsh-users@math.gatech.edu>
Subject: Re: rolling over high-traffic logfiles?
Date: Wed, 15 Jul 1998 22:08:51 -0700	[thread overview]
Message-ID: <980715220851.ZM13527@candle.brasslantern.com> (raw)
In-Reply-To: <19980715234957.51065@astaroth.nit.gwu.edu>

On Jul 15, 11:49pm, Sweth Chandramouli wrote:
} Subject: rolling over high-traffic logfiles?
}
} 	is there some easy way to roll over high-traffic logfiles
} in zsh, without losing any possible incoming data?

There isn't any magic for this that is specific to zsh.

} can zsh do some sort of file locking here?

It wouldn't help.  The processes that are writing to the log file would
also have to use the equivalent locking.  (There is such a thing in unix
as "mandatory" file locking, but using that would likely just cause the
logging processes to get errors.  All other locking is "advisory," which
means all processes involved must have been written so as to use the same
cooperative calls.)

} does anyone have any other ideas on how to not lose and log entires?

Use "ln" and "mv" to replace the file, rather than "cp" over it.

	cp /dev/null extlog.new &&
	ln extlog extlog.`date` &&
	mv -f extlog.new extlog ||
	rm -f extlog.new

There's still a race condition where some process could attempt to write
to extlog during the execution of "mv", that is, between unlinking the
old extlog and renaming extlog.new to extlog.  However, the window for
failure is much smaller, and could be made smaller still by using the
"files" module with zsh 3.1.4 so that "ln" and "mv" are shell builtins.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-07-16  5:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-16  3:49 Sweth Chandramouli
1998-07-16  5:08 ` Bart Schaefer [this message]
1998-07-16  8:36   ` Zefram
1998-07-16 12:46   ` Brian Harvell
1998-07-16 15:26     ` Bart Schaefer
1998-07-16 16:14       ` Zefram
1998-07-16 16:41         ` Nitin P Garg
1998-07-17  7:36           ` Jos Backus
1998-07-24 23:42       ` Todd Graham Lewis
1998-07-16 13:45 ` Duncan Sinclair

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980715220851.ZM13527@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=sweth@astaroth.nit.gwu.edu \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).