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);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to