UpdateController/log_helpers.sh

18 lines
393 B
Bash
Raw Normal View History

#!/bin/bash
# set -x
log() {
local log_file=/var/log/update_controller.log
if [ -f "$log_file" ]; then
touch $log_file
fi
if [ $(wc -l < $log_file) > 100000 ]; then
# remove first line
sed -e 1d -i $log_file
fi
message="$(date +'%D_%T'): $*"
printf "$message\n"
printf "$message\n" >> $log_file
}
# log "test message1" "test message2"