summaryrefslogtreecommitdiffstats
path: root/usr.sbin/newsyslog
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2013-01-03 16:14:51 +0000
committermarkj <markj@FreeBSD.org>2013-01-03 16:14:51 +0000
commitfe63c3a52ae03ef9724b8d4af06597b8a77e7064 (patch)
tree84b11dabc6df95793ea21458180ea6863f3964c2 /usr.sbin/newsyslog
parente8588e6c07393ac104cb6bf5e726e1dea408f9aa (diff)
downloadFreeBSD-src-fe63c3a52ae03ef9724b8d4af06597b8a77e7064.zip
FreeBSD-src-fe63c3a52ae03ef9724b8d4af06597b8a77e7064.tar.gz
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
Diffstat (limited to 'usr.sbin/newsyslog')
-rw-r--r--usr.sbin/newsyslog/newsyslog.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index ee90b99..42cc013 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -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);
}
OpenPOWER on IntegriCloud