From owner-freebsd-questions@FreeBSD.ORG Thu Jun 12 11:58:36 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5804A37B401 for ; Thu, 12 Jun 2003 11:58:36 -0700 (PDT) Received: from web1.nexusinternetsolutions.net (web1.nexusinternetsolutions.net [206.47.131.12]) by mx1.FreeBSD.org (Postfix) with SMTP id 67D4043F85 for ; Thu, 12 Jun 2003 11:58:35 -0700 (PDT) (envelope-from dave@hawk-systems.com) Received: (qmail 37958 invoked from network); 12 Jun 2003 18:58:33 -0000 Received: from unknown (HELO ws1) (24.157.103.51) by web1.nexusinternetsolutions.net with SMTP; 12 Jun 2003 18:58:33 -0000 From: "Dave [Hawk-Systems]" To: Date: Thu, 12 Jun 2003 14:58:32 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: shell scripting - automating rotation of files in different directories X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jun 2003 18:58:36 -0000 have looked at a couple of the ports for log rotation and such, but none seem to come close to the simplicity and complexity of what I am looking for. have user directories and log files in each directory... each user requests to have 1 day ro 30 days of logs made available for them to download at any given time. Looking for a way to simply touch or delete log files and have the script identify the correct rotation to. For example, for($i=30; $i>0;$1--){ # 30 days is maximum retained for LOG in `ls /users/*/logs/ | grep .$i'`; do # move any of the previous logs into the current existing # so that we don't add to number of logs per user $prevLOG = strreplace(($i-1)($i) on $LOG) mv $prevLOG $LOG done ) this way, if a user wants more logs, just touch (create empty) logs files, and the next time the script runs it will rotate all them... need less, simply delete the unneeded log files and they will not be rotated into. Am thinking that the shell script will need to drop to awk to perform the disection of the log number extensions... any thoughts on this/easier methods before I sit down and devote some time to it? thanks Dave