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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
I'll take a look...
Can you run again with the "-d" command line option added?
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>
Thanks, so I see that it sees the postrotate section...I'll get back to you hopefully soon
Okay I have compiled a version to test with...let me know how this works for you
Worked like a charm! Thanks!
Glad to hear it...I will package this up and make it official shortly.
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