Add date and time to log file name
This commit is contained in:
parent
eaa12cc596
commit
ddc012ba11
1 changed files with 3 additions and 10 deletions
|
@ -1,19 +1,12 @@
|
||||||
log () {
|
log () {
|
||||||
m_time=`date "+%F %T"`
|
m_time=`date "+%F %T"`
|
||||||
echo $m_time" :: $scriptName :: $scriptVersion :: "$1 2>&1 | tee -a /config/logs/$scriptName.txt
|
echo $m_time" :: $scriptName :: $scriptVersion :: "$1 2>&1 | tee -a /config/logs/$scriptName-$(date +"%Y_%m_%d_%I_%M_%p").txt
|
||||||
}
|
}
|
||||||
|
|
||||||
logfileSetup () {
|
logfileSetup () {
|
||||||
# auto-clean up log file to reduce space usage
|
|
||||||
if [ -f "/config/logs/$scriptName.txt" ]; then
|
|
||||||
if find /config/logs -type f -name "$scriptName.txt" -size +1024k | read; then
|
|
||||||
echo "" > /config/logs/$scriptName.txt
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "/config/logs/$scriptName.txt" ]; then
|
if [ ! -f "/config/logs/$scriptName.txt" ]; then
|
||||||
echo "" > /config/logs/$scriptName.txt
|
echo "" > /config/logs/$scriptName-$(date +"%Y_%m_%d_%I_%M_%p").txt
|
||||||
chmod 666 "/config/logs/$scriptName.txt"
|
chmod 666 "/config/logs/$scriptName-_$(date +"%Y_%m_%d_%I_%M_%p").txt"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue