From owner-freebsd-hackers Sun Jan 18 08:23:32 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA20374 for hackers-outgoing; Sun, 18 Jan 1998 08:23:32 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from androcles.com (dhh@androcles.com [204.57.240.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA20333 for ; Sun, 18 Jan 1998 08:23:10 -0800 (PST) (envelope-from alex@androcles.com) Received: (from dhh@localhost) by androcles.com (8.8.7/8.8.7) id IAA00382; Sun, 18 Jan 1998 08:22:45 -0800 (PST) Message-ID: X-Mailer: XFMail 1.1 [p0] on FreeBSD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit MIME-Version: 1.0 In-Reply-To: <199801171840.QAA16473@gaia.coppe.ufrj.br> Date: Sun, 18 Jan 1998 08:15:48 -0800 (PST) From: "Duane H. Hesser" To: Joao Carlos Mendes Luis Subject: Re: 2nd call for comments: New option for newsyslog Cc: freebsd-hackers@FreeBSD.ORG, danny@panda.hilink.com.au, (Tom) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk On 17-Jan-98 Joao Carlos Mendes Luis wrote: [snip] > >Maybe it would be better to make a generic shell script to do file >rotation. It would need some flags, like gzip compression needed, >etc. It could be used by user scripts also. I have some that would >be much simpler with such program available. > The smail 3 distribution contains a shell script 'savelog' which does this very nicely. FYI, Here are the comments from the script. #! /bin/sh # @(#) $Id: savelog.sh,v 1.5 1992/07/11 11:40:30 tron Exp $ # # savelog - save a log file # # Copyright (C) 1987, 1988 Ronald S. Karr and Landon Curt Noll # Copyright (C) 1992 Ronald S. Karr # # See the file COPYING, distributed with smail, for restriction # and warranty information. # # usage: savelog [-m mode] [-u user] [-g group] [-t] [-c cycle] [-l] file... # # -m mode - chmod log files to mode # -u user - chown log files to user # -g group - chgrp log files to group # -c cycle - save cycle versions of the logfile (default: 7) # -t - touch file # -l - don't compress any log files (default: compress) # file - log file names # # The savelog command saves and optionally compresses old copies of files # into an 'dir'/OLD sub-directory. The 'dir' directory is determined from # the directory of each 'file'. # # Older version of 'file' are named: # # OLD/'file'. # # where is the version number, 0 being the newest. By default, # version numbers > 0 are compressed (unless -l prevents it). The # version number 0 is never compressed on the off chance that a process # still has 'file' opened for I/O. # # If the 'file' does not exist or if it is zero length, no further processing # is performed. However if -t was also given, it will be created. # # For files that do exist and have lengths greater than zero, the following # actions are performed. # # 1) Version numered files are cycled. That is version 6 is moved to # version 7, version is moved to becomes version 6, ... and finally # version 0 is moved to version 1. Both compressed names and # uncompressed names are cycled, regardless of -t. Missing version # files are ignored. # # 2) The new OLD/file.1 is compressed and is changed subject to # the -m, -u and -g flags. This step is skipped if the -t flag # was given. # # 3) The main file is moved to OLD/file.0. # # 4) If the -m, -u, -g or -t flags are given, then file is created # (as an empty file) subject to the given flags. # # 5) The new OLD/file.0 is chanegd subject to the -m, -u and -g flags. # # Note: If the OLD sub-directory does not exist, it will be created # with mode 0755. # # Note: If no -m, -u or -g flag is given, then the primary log file is # not created. # # Note: Since the version numbers start with 0, version number # is never formed. The count must be at least 2. # # Bugs: If a process is still writing to the file.0 and savelog # moved it to file.1 and compresses it, data could be lost. # Smail does not have this problem in general because it # restats files often. > >// > As for the daily and weekly options, there are always 24 hours in a day >// > and 168 hours in a week, so fixed period rotations are correctly handled. >// > Or are they? In fact, rotating every 24 or 168 hours may not be what was >// > wanted, if the sysadmin really wants the files rotated as close as >// > possible to midnight with the week starting on Sunday. >// >// In some cases, accurate midnight rotation is critical. > For accurate midnight rotation, use '@daily' (or @weekly, @monthly) in your root crontab. The wheels are reasonably round...why re-invent them? -------------- Duane H. Hesser dhh@androcles.com