On Thu, Apr 11, 2024 at 12:07 AM Brian Reichert <reichert@xxxxxxxxxxx> wrote: > > On Wed, Apr 10, 2024 at 01:47:47PM -0600, Dan Nicholson wrote: > > Restarting the timer doesn't make the service run immediately. Are you > > sure logrotate.service has run again since you made this change? Just > > simulate the timer and start logrotate.service again. All the timer > > does is activate the service. For testing you don't need to wait for > > that to happen. > > Ok, that is a helpful detail. > > Restarting logrotate.service does now cause my post-logrotate.service > to subsequently start. > > On a lark, I augmented the stock logrotate.service with some > instrumentation to show me when 'logrotate' completes, in addition to > maintaining a log file: > > #ExecStart=/usr/sbin/logrotate /etc/logrotate.conf > ExecStart=/usr/sbin/logrotate -l /var/log/logrotate.log /etc/logrotate.conf > ExecStartPost=/usr/bin/logger 'XXX log rotation completed' > > My service is being run (yay!), but I'm wary of the out-of-order > messaging here: > Show full unit definition for both logrotate.service and your service. > 10-153-68-34:~ # journalctl -o short-precise --no-pager -u logrotate.service -u post-logrotate.service | tail -6 > Apr 10 16:57:54.061053 10-153-68-34 systemd[1]: Started Activities after logrotation. > Apr 10 16:57:54.061140 10-153-68-34 systemd[1]: Stopped Rotate log files. > Apr 10 16:57:54.062219 10-153-68-34 systemd[1]: Starting Rotate log files... > Apr 10 16:57:54.104300 10-153-68-34 root[5899]: XXX post log rotation > Apr 10 16:57:55.367522 10-153-68-34 root[5903]: XXX log rotation completed > Apr 10 16:57:55.368789 10-153-68-34 systemd[1]: Started Rotate log files. > > And systemctl shows the new post-logrotate.service started slightly > before logrotate.service ended: > > 10-153-68-34:~ # systemctl show logrotate.service --property ExecMainExitTimestamp > ExecMainExitTimestamp=Wed 2024-04-10 16:57:55 EDT > 10-153-68-34:~ # systemctl show post-logrotate.service --property ExecMainStartTimestamp > ExecMainStartTimestamp=Wed 2024-04-10 16:57:54 EDT > > (I really wish I had higher-resolution timestamps here.) > > That log file's mtime: > > 10-153-68-34:~ # ls -ldtr --full-time /var/log/logrotate.log > -rw-r--r-- 1 root root 1607975 2024-04-10 16:57:55.094420531 -0400 /var/log/logrotate.log > > Hopefully someone here can assure me this is just due to an artifact > of bookkeeping. I'm specifically trying to avoid doing any work > while logrotate is running. > > That I got even this far is really great, so I appreciate all of the > guidance! > > > -- > > Dan > > -- > Brian Reichert <reichert@xxxxxxxxxxx> > BSD admin/developer at large