For those who has log size problem
I wrote some thing until we think of a new way either named pipe, tmpfs, ramfs or ...
3main after :
if [ $CLEAR_LOGS_ON_BOOT == "YES" ]
then
sudo bash '/home/m1/clear_logs'
fi
ADD:
if [ $LOG_ROTATE == "YES" ]
then
HCD='/home/m1/log_rotate'
running=$(ps -ef | awk '$NF~"log_rotate" {print $2}')
if [ "$running" == "" ]
then
guake -n $HCD -r LOG_ROTATE -e "bash /home/m1/log_rotate"
running=""
fi
fi
1bash after :
CLEAR_LOGS_ON_BOOT="NO" # YES NO
ADD:
$LOG_ROTATE="YES"
$LOG_ROTATE_INTERVAL=12 # Time between log rotations in hours
And make a new file
/home/m1/log_rotate
#!/bin/bash
source /home/m1/1bash
while true
do
TIMEIN=$LOG_ROTATE_INTERVAL
TIMEOUT=$(($TIMEIN * 3600))
# Rotating wdog logs
WDOG_LOG_FILE="/home/m1/5_restartlog"
if [ -e "$WDOG_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$( cat $WDOG_LOG_FILE | tail -n 2k)" > $WDOG_LOG_FILE
fi
# Rotating wdog alerts log
WDOG_ALERT_LOG_FILE="/home/m1/7_wdog_alertlog"
if [ -e "$WDOG_ALERT_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$( cat $WDOG_ALERT_LOG_FILE | tail -n 2k)" > $WDOG_ALERT_LOG_FILE
fi
# Rotating temp logs
TEMP_LOG_FILE="/home/m1/6_autotemplog"
if [ -e "$TEMP_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$( cat $TEMP_LOG_FILE | tail -n 2k)" > $TEMP_LOG_FILE
fi
# Rotating temp alerts
TEMP_ALERT_LOG_FILE="/home/m1/7_temp_alertlog"
if [ -e "$TEMP_ALERT_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$( cat $TEMP_ALERT_LOG_FILE | tail -n 2k)" > $TEMP_ALERT_LOG_FILE
fi
# Rotating miner screenlog
MINER_LOG_FILE="/home/m1/screenlog.0"
if [ -e "$MINER_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$( cat $MINER_LOG_FILE | tail -n 2k)" > $MINER_LOG_FILE
fi
echo "Rotate again in $TIMEIN Hours"
sleep $TIMEOUT
done
Hope it helps you for now.