Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jan 2013 16:14:51 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244997 - head/usr.sbin/newsyslog
Message-ID:  <201301031614.r03GEpGi040370@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Jan  3 16:14:51 2013
New Revision: 244997
URL: http://svnweb.freebsd.org/changeset/base/244997

Log:
  Make sure to update the mtime of a logfile after archiving it. This
  ensures that the next rotation happens at the correct time when using
  interval-based rotations.
  
  PR:		bin/174438
  Reviewed by:	gad
  Approved by:	rstone (co-mentor)
  MFC after:	1 week

Modified:
  head/usr.sbin/newsyslog/newsyslog.c

Modified: head/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- head/usr.sbin/newsyslog/newsyslog.c	Thu Jan  3 16:12:48 2013	(r244996)
+++ head/usr.sbin/newsyslog/newsyslog.c	Thu Jan  3 16:14:51 2013	(r244997)
@@ -1814,12 +1814,21 @@ do_rotate(const struct conf_entry *ent)
 				printf("\tcp %s %s\n", ent->log, file1);
 			else
 				printf("\tln %s %s\n", ent->log, file1);
+			printf("\ttouch %s\t\t"
+			    "# Update mtime for 'when'-interval processing\n",
+			    file1);
 		} else {
 			if (!(flags & CE_BINARY)) {
 				/* Report the trimming to the old log */
 				log_trim(ent->log, ent);
 			}
 			savelog(ent->log, file1);
+			/*
+			 * Interval-based rotations are done using the mtime of
+			 * the most recently archived log, so make sure it gets
+			 * updated during a rotation.
+			 */
+			utimes(file1, NULL);
 		}
 		change_attrs(file1, ent);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301031614.r03GEpGi040370>