Menu

Postrotate command not running

2017-02-28
2018-09-19
  • John Nichel

    John Nichel - 2017-02-28

    My Config:

    D:\Logs\SERVER-07.log {
    rotate 5
    daily
    prerotate
    net stop MySQL57
    endscript
    postrotate
    net start MySQL57
    endscript
    }

    Running logrotate manually:

    C:\Program Files (x86\LogRotate>logrotate.exe -f -v d:\Logs\log_rotate.conf.txt
    logrotate: Force option set to true
    logrotate: logrotate 0.0.0.17 - Copyright (C) 2012-2016 Ken Salter
    logrotate: Verbose option set to true
    logrotate: d:\Logs\log_rotate.conf.txt Adding to config files to process
    logrotate: Parsing configuration file d:\Logs\log_rotate.conf.txt
    logrotate: Processing new section
    logrotate: Processing D:\Logs\SERVER-07.log
    logrotate: Force option is set, will rotate
    logrotate: Rotating file D:\Logs\SERVER-07.log
    logrotate: Executing C:\Windows\system32\cmd.exe /S /C ""C:\Users\jnichel\AppDat
    a\Local\Temp\2\tmp60D3.cmd" "D:\Logs\SERVER-07.log""
    logrotate:
    C:\Program Files (x86\LogRotate>net stop MySQL57
    The MySQL57 service is stopping.....
    The MySQL57 service was stopped successfully.

    logrotate: Examining filename SERVER-07.log.1
    logrotate: Renaming D:\Logs\SERVER-07.log.1 to D:\Logs\SERVER-07.log.2
    logrotate: Compressing rotated log file D:\Logs\SERVER-07.log.2
    logrotate: Deleting file D:\Logs\SERVER-07.log.2
    logrotate: Renaming D:\Logs\SERVER-07.log to D:\Logs\SERVER-07.log.1
    logrotate: Renaming D:\Logs\SERVER-07.log to D:\Logs\SERVER-07.log.1

    C:\Program Files (x86\LogRotate>

    MySQL stops fine to allow the log to rotate, but nothing for postrotate.

     
  • Ken Salter

    Ken Salter - 2017-02-28

    I'll take a look...

     
  • Ken Salter

    Ken Salter - 2017-02-28

    Can you run again with the "-d" command line option added?

     
  • John Nichel

    John Nichel - 2017-02-28

    C:\Program Files (x86\LogRotate>logrotate.exe -d -f -v d:\Logs\log_rotate.conf.txt
    logrotate: Debug option set to true
    logrotate: Verbose option set to true
    logrotate: Force option set to true
    logrotate: logrotate 0.0.0.17 - Copyright (C) 2012-2016 Ken Salter
    logrotate: Verbose option set to true
    logrotate: d:\Logs\log_rotate.conf.txt Adding to config files to process
    logrotate: Parsing configuration file d:\Logs\log_rotate.conf.txt
    logrotate: read line D:\Logs\SERVER-07.log {
    logrotate: Processing new section
    logrotate: read line rotate 5
    logrotate: Setting rotate to 5
    logrotate: read line daily
    logrotate: Setting daily to True
    logrotate: read line prerotate
    logrotate: Setting prerotate to True
    logrotate: read line net stop MySQL57
    logrotate: read line endscript
    logrotate: read line postrotate
    logrotate: Setting postrotate to True
    logrotate: read line net start MySQL57
    logrotate: read line endscript
    logrotate: read line }
    logrotate: Processing D:\Logs\SERVER-07.log
    logrotate: Force option is set, will rotate
    logrotate: Rotating file D:\Logs\SERVER-07.log
    logrotate: Rotate will be simulated because Debug is true
    logrotate: Script file path: C:\Users\jnichel\AppData\Local\Temp\2\tmp9565.cmd
    logrotate: Deleting file C:\Users\jnichel\AppData\Local\Temp\2\tmp9565.cmd
    logrotate: Examining filename SERVER-07.log.2.gz
    logrotate: Renaming D:\Logs\SERVER-07.log.2.gz to D:\Logs\SERVER-07.log.3.gz
    logrotate: Examining filename SERVER-07.log.1
    logrotate: Renaming D:\Logs\SERVER-07.log.1 to D:\Logs\SERVER-07.log.2
    logrotate: Renaming D:\Logs\SERVER-07.log to D:\Logs\SERVER-07.log.1
    logrotate: Compressing rotated log file D:\Logs\SERVER-07.log.1
    logrotate: Script file path: C:\Users\jnichel\AppData\Local\Temp\2\tmp9576.cmd
    logrotate: Deleting file C:\Users\jnichel\AppData\Local\Temp\2\tmp9576.cmd

    C:\Program Files (x86\LogRotate>

     
  • Ken Salter

    Ken Salter - 2017-02-28

    Thanks, so I see that it sees the postrotate section...I'll get back to you hopefully soon

     
  • Ken Salter

    Ken Salter - 2017-02-28

    Okay I have compiled a version to test with...let me know how this works for you

     
  • John Nichel

    John Nichel - 2017-02-28

    Worked like a charm! Thanks!

     
  • Ken Salter

    Ken Salter - 2017-02-28

    Glad to hear it...I will package this up and make it official shortly.

     
  • Peter

    Peter - 2018-09-19

    Ken: With 0.18 I'm getting the same as with with both pre and post with "net start/stop service_name", ditto same behavior with first/lastaction (from debug):

    logrotate: read line firstaction
    logrotate: Setting firstaction to True
    logrotate: read line net stop syslog-ng
    logrotate: read line endscript
    logrotate: read line }

    Service not stopping (nor starting). BTW (more a feature request) would love if somehow that was a blocking command, i.e. "Don't proceed to next rotation until action retursn positive error code or something" (mostly becuase some services take a minute or five to stop and I'm not sure how LR handles that)

     

    Last edit: Peter 2018-09-19

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.