Added cleaning logs to discard older logs as not need while developing

This commit is contained in:
Luca Haid
2024-05-10 23:09:33 +02:00
parent 1f30671cf9
commit e90ecc020e
2 changed files with 20 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# Variables
LOG_DIR="/var/log/apache2"
ERROR_LOG="${LOG_DIR}/error.log"
ACCESS_LOG="${LOG_DIR}/access.log"
LINES_TO_KEEP=50
# Truncate logs to keep only the last 50 lines
tail -n $LINES_TO_KEEP $ERROR_LOG > ${ERROR_LOG}.tmp && mv ${ERROR_LOG}.tmp $ERROR_LOG
tail -n $LINES_TO_KEEP $ACCESS_LOG > ${ACCESS_LOG}.tmp && mv ${ACCESS_LOG}.tmp $ACCESS_LOG