From 83f547e79a5f3e08d21d930b427fb65202a8d1d6 Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Fri, 20 Jul 2012 05:19:50 +0100 Subject: [PATCH] Added protection against rolling server logs when the log is empty. --- init/msm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/init/msm b/init/msm index 30f1597..bed02d1 100755 --- a/init/msm +++ b/init/msm @@ -1347,7 +1347,14 @@ server_log_roll() { # Moves and Gzips the logfile, a big log file slows down the # server A LOT - printf "Rolling server logs... " + local log_lines="$(cat "${SERVER_LOG_PATH[$1]}" | wc -l )" + + if [ "$log_lines" -le '1' ]; then + echo "No new log enteries to roll. No change made." + return 0 + fi + + echo -n "Rolling server logs... " if [ -e "${SERVER_LOG_PATH[$1]}" ]; then file_name="${SERVER_NAME[$1]}-$(date +%F-%H-%M-%S).log"