From owner-freebsd-questions Tue Jan 15 19: 9:47 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id C769C37B400 for ; Tue, 15 Jan 2002 19:09:42 -0800 (PST) Received: from hades.hell.gr (patr530-a002.otenet.gr [212.205.215.2]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id g0G398o23036; Wed, 16 Jan 2002 05:09:14 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id g0G38Mq29952; Wed, 16 Jan 2002 05:08:23 +0200 (EET) (envelope-from keramida@FreeBSD.org) Date: Wed, 16 Jan 2002 05:08:22 +0200 From: Giorgos Keramidas To: ann kok Cc: Jan Grant , questions Subject: Re: crontab to backup mail in date format Message-ID: <20020116030821.GA25005@hades.hell.gr> References: <20020116024727.49626.qmail@web20108.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020116024727.49626.qmail@web20108.mail.yahoo.com> User-Agent: Mutt/1.3.25i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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