I am currently working on script with the following goals:
- Script will check every 15-minute if there is
/logsdirectory. There are numerous apps in
/logsdirectory, for example
- If there is
AppA.log4, it will be renamed to
zipthe renamed file and move to
So far, I have created working script however it is hardcoded.
Can you help improving this to be more dynamic? For example,
AppB.log4 will be moved and zipped, leaving
AppC.log4 in the
What if there's a separate file that lists all the App (
AppB) that will be read by this script. How can I apply it here. Thank you in advance.
TIMESTAMP=`date "+%Y.%m.%d-%H.%M"` LOGS="AppA.log.4" APPLOGS_DIR="/logs/" BACKUP_DIR="/backupDIR/" cd $APPLOGS_DIR; if [ -f "$LOGS" ]; then mv $LOGS $BACKUP_DIR; cd $BACKUP_DIR; mv $LOGS AppA_$TIMESTAMP; gzip AppA_$TIMESTAMP; else echo "No log file to be backed up" fi