Update run_daemon.sh
keep the initial log file
# - Lorenzo Bernardi (@fastlorenzo)
#
+# INIT-LOGFILE is the first log file created
+# Keep it for root cause analysis
LOGFILE="/var/log/redelk/daemon.log"
+INIT-LOGFILE="/var/log/redelk/init-daemon.log"
+
# du default size listing is 1024B/1KB
# 2 MB = 2048
MAXLOGSIZE=$((1024*50))
@@ -19,8 +23,14 @@ DAEMON_RUNNING=$?
if [ $DAEMON_RUNNING -eq 1 ]; then
cd /usr/share/redelk/bin
+ # Check if file is larger than max log size
+ # We want to keep the first log file for troubleshooting
CURRENTLOGSIZE=$(/usr/bin/du $LOGFILE | /usr/bin/cut -f1)
if [ $CURRENTLOGSIZE -gt $MAXLOGSIZE ];then
+ if [ ! -f "$INIT-LOGFILE" ]; then
+ /usr/bin/mv $LOGFILE $INIT-LOGFILE
+ fi
+
/usr/share/redelk/bin/daemon.py > $LOGFILE 2>&1
else
/usr/share/redelk/bin/daemon.py >> $LOGFILE 2>&1
