You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

18 lines
298 B

#!/bin/bash
LOGFILE=log.log
RETAIN_NUM_LINES=10
function logsetup {
TMP=$(tail -n $RETAIN_NUM_LINES $LOGFILE 2>/dev/null) && echo "${TMP}" > $LOGFILE
exec > >(tee -a $LOGFILE)
exec 2>&1
}
function log {
echo "[$(date --rfc-3339=seconds)]: $*"
}
logsetup
log hello this is a log