openenergymonitor / EmonScripts

Emoncms Stack Installation and Update scripts
16 stars 30 forks source link

Modify logrotate schema #163

Closed borpin closed 1 year ago

borpin commented 1 year ago

Modify the logrotate commands to ensure all logs get rotated to the SD card by log2ram.

Changes as well because of changes to Logrotate itself.

155 refers

borpin commented 1 year ago

Also fixes #152 and https://github.com/openenergymonitor/EmonScripts/issues/6

TrystanLea commented 1 year ago

Thanks @borpin I haven't tested this yet but assume this is working ok for you there? thanks for looking into this

alexandrecuer commented 1 year ago

@borpin : sure you dont need copytruncate for emonhub ? it is the only way when some programs cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever, ie nowhere

cf https://man7.org/linux/man-pages/man8/logrotate.8.html

borpin commented 1 year ago

sure you dont need copytruncate for emonhub ?

Have you read through #155 That should explain the package changes.

borpin commented 1 year ago

Thanks @borpin I haven't tested this yet but assume this is working ok for you there? thanks for looking into this

Yes working for me and removes the errors.

alexandrecuer commented 1 year ago

sure you dont need copytruncate for emonhub ?

Have you read through #155 That should explain the package changes.

Yes I read it but cannot understand through my readings why you dont need copytruncate for emonhub as it will not close its log unless something internal has been implemented into emonhub which I do not have knowledge what I understood perfectly is that copytruncate and renamecopy options cannot work together.

borpin commented 1 year ago

I'm sure I came across something somewhere that said you could not use copytruncate' ifolddir` was pointing to a different partition or device. I cannot find it again so I think I may have been wrong in that.

Looking at man, I think I may have misread this (or I found an old man page)

image

I am also sure I was getting an error with copytruncate.

Yes, I was - from #155

error: emoncms:6 olddir /var/log.old/emoncms and log file /var/log/emoncms/apache2-error.log are on different devices

I'll rebuild an SD card and test.

borpin commented 1 year ago

Ok, so in the log2ram config it has the renamecopy.

However, this should probably be in the main logrotate files as well.

I'm not sure though, if this will conflict with old systems!