[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FWD: About Bash Script
From: |
Greg Wooledge |
Subject: |
Re: FWD: About Bash Script |
Date: |
Mon, 15 Feb 2010 17:04:01 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Feb 15, 2010 at 10:20:05PM +0100, Mart Frauenlob wrote:
> > From: Curt <caincc1@gmail.com>
> > What I want to do is simply if the destination file exists, instead it
> > creates an index number and appends that to the name.
> >
> > If b.txt exists then a.txt will be renamed to b.txt.1, but if b.txt.1
> > exists then it will be renamed to b.txt.2
Sounds like you're rotating logs. I prefer multilog from daemontools
(http://cr.yp.to/daemontools.html) if it's a serious job. If it's a
casual job, then I like to keep it nice and simple:
mv b.txt.1 b.txt.2 >/dev/null 2>&1
mv b.txt b.txt.1 >/dev/null 2>&1
> b.txt
chown someuser:somegroup b.txt
chmod some-permission-string b.txt
kill -HUP $(cat some-pid-file)
# Or /some/daemon reload, whatever
Keeps a constant number of rotated backups, no complexity, no bashisms.
I suppose if you're a Linux user, you'll want to look at rotatelog (or
is it logrotate) instead, because that's more complex.
- FWD: About Bash Script, Mart Frauenlob, 2010/02/15
- Re: FWD: About Bash Script,
Greg Wooledge <=
- Re: FWD: About Bash Script, Curtis, 2010/02/15
- Message not available
- Re: FWD: About Bash Script, Curtis, 2010/02/16
- Re: FWD: About Bash Script, pk, 2010/02/16
- Re: FWD: About Bash Script, Curtis, 2010/02/16
- Re: FWD: About Bash Script, Curtis, 2010/02/16
- Re: FWD: About Bash Script, pk, 2010/02/16
- Re: FWD: About Bash Script, Mart Frauenlob, 2010/02/16
- Re: FWD: About Bash Script, Curtis, 2010/02/16