Date: Wed, 16 Jan 2002 05:08:22 +0200 From: Giorgos Keramidas <keramida@FreeBSD.org> To: ann kok <annkok2001@yahoo.com> Cc: Jan Grant <Jan.Grant@bristol.ac.uk>, questions <questions@FreeBSD.org> Subject: Re: crontab to backup mail in date format Message-ID: <20020116030821.GA25005@hades.hell.gr> In-Reply-To: <20020116024727.49626.qmail@web20108.mail.yahoo.com> References: <Pine.GSO.4.31.0201141625490.20828-100000@mail.ilrt.bris.ac.uk> <20020116024727.49626.qmail@web20108.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-01-15 18:47:27, ann kok wrote:
> --- Dear Jan
>
> Thank you. It works now
>
> But how do I know that % doesn't work in crontab?
>
> BTW, I met another problem. There will be many backup
> in the server by date format
>
> How do I create cron to delete the date format backup
> after 3 days automatically again?
Sort backup archives by date, and erase everything that is older than
3 days. If you have files called:
% ls -1 mail.*
mail.2002.01.08.tar.gz
mail.2002.01.09.tar.gz
mail.2002.01.10.tar.gz
mail.2002.01.11.tar.gz
mail.2002.01.12.tar.gz
and you want to erase all but the 3 last, you can use commands like:
% ls -1 mail.*.tar.gz | sort -3 | sed -e '1,3d'
to view what would be deleted, and then use `xargs rm' to erase them:
% ls -1 mail.*.tar.gz | sort -3 | sed -e '1,3d' | xargs rm -f
--
Giorgos Keramidas . . . . . . . . . keramida@{ceid.upatras.gr,freebsd.org}
FreeBSD Documentation Project . . . http://www.freebsd.org/docproj/
FreeBSD: The power to serve . . . . http://www.freebsd.org/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020116030821.GA25005>
