Skip to content

Instantly share code, notes, and snippets.

@tomhat
Created March 10, 2020 09:58
Show Gist options
  • Save tomhat/a1ddfcd1b8e283674ea8247af2b52a04 to your computer and use it in GitHub Desktop.
Save tomhat/a1ddfcd1b8e283674ea8247af2b52a04 to your computer and use it in GitHub Desktop.
Simple Application's LogRotate Shell
#!/bin/bash
logterm=14
logpath="***LOGPATH***"
logfile="app.log"
fullname=$logpath$logfile
newlogfilename=$logpath${logfile%.*}.`date '+%Y%m%d' -d "1 days ago"`.log
dellogfilename=$logpath${logfile%.*}.`date '+%Y%m%d' -d "$logterm days ago"`.log
cp $fullname $newlogfilename
echo "" > $fullname
if [ -e ${dellogfilename} ]; then
rm -rf ${dellogfilename}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment