logrotate as daemon, logfile 5000

This commit is contained in:
oliver
2026-08-14 16:47:31 -03:00
parent 729b24edd8
commit c8111645e4
4 changed files with 45 additions and 1 deletions
+1 -1
View File
@@ -501,7 +501,7 @@ async def get_odoo_log_summary(uuid: str):
# --- Main logic ---
try:
# Last 500 lines from Odoo log
last_500_lines = read_last_lines(odoo_log_file, 500)
last_500_lines = read_last_lines(odoo_log_file, 5000)
important_odoo_lines = [
line for line in last_500_lines if is_important_line(line)
]
+15
View File
@@ -1,8 +1,21 @@
#!/bin/bash
# rotateLogs — rotate odoo.log for all UUID containers, keep 4 weeks
# Runs as a daemon: waits for midnight, rotates, then waits for next midnight
RETENTION_DAYS=28
wait_for_midnight() {
NOW=$(date +%s)
MIDNIGHT=$(date -d 'tomorrow 00:00' +%s 2>/dev/null || \
date -d "$(date -d tomorrow '+%Y-%m-%d') 00:00:00" +%s)
SLEEP=$(( MIDNIGHT - NOW ))
echo "Waiting ${SLEEP}s until midnight..."
sleep "$SLEEP"
}
while true; do
wait_for_midnight
for log in /4server/data/00*/logs/odoo.log; do
[[ -f "$log" ]] || continue
DIR=$(dirname "$log")
@@ -28,3 +41,5 @@ for log in /4server/data/00*/logs/odoo.log; do
find "$DIR" -name 'odoo.log.*.gz' -mtime +$RETENTION_DAYS -exec rm -f {} \; \
-exec echo "$UUID deleted: {}" \;
done
done