openenergymonitor / EmonScripts

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

Once `/var/log` fills up the update can no longer run #159

Open borpin opened 1 year ago

borpin commented 1 year ago

85 solves the issue of logrotate not rotating it's own logs. However it does not solve the issue of once /var/log fills up the update can no longer run.

@TrystanLea what do you think of adding a check right at the beginning of the update script to check if if /var/log is full and if so truncate the largest log? As suggested by @borpin on this thread. Or maybe use a different location for emonpiupdate.log?

Originally posted by @glynhudson in https://github.com/openenergymonitor/EmonScripts/issues/81#issuecomment-642104437

TrystanLea commented 1 year ago

Ok so will still need a script of some sort to check and clear logs if full ? Should the logrotate config not fix this by ensuring that the sum of all logs cannot exceed the log partition size?

borpin commented 1 year ago

Ok so will still need a script of some sort to check and clear logs if full ? Should the logrotate config not fix this by ensuring that the sum of all logs cannot exceed the log partition size?

Yes, this problem may be so old as to ignore now. I doubt there are any systems still out there that are unable to update because of this.

borpin commented 1 year ago

Ha, yes there could be - had an emonhub log fill up :(

CDuffers commented 1 year ago

Morning,

Checking and clearing space before we run is always a good thing to do.

I suggest that we need to enhance the error checking through the scripts to pick up this and any other quirks and foibles along the way.

I'm working on an enhancement to emoncms-export.sh within the backup module, my current approach is to run a trap on error which shows the RC and LINENO before allowing it to continue, then also a trap on EXIT to summarise if it completed successfully or with error. The idea being to highlight a problem rather than stop and perform some more invasive controls, which I thought was too strong a change at this point.

This might be helpful for the install and update scripts as well as it MIGHT have highlighted the root cause from this issue https://github.com/openenergymonitor/EmonScripts/issues/179

This is likely to requite rethinking of some code to prevent non-zero return codes for commands like grep when it can't find something. e.g. $(ls /boot | grep emonSD) when run on my Ubuntu VM