linux:purging_script
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
purging_script [2013/10/10 10:24] – dodger | linux:purging_script [2022/02/11 11:36] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== [SCRIPT] Purge script ====== | ||
+ | |||
====== Description ====== | ====== Description ====== | ||
Have you ever fight with logrotate configuration files? Did you survived? Cool, this document is not for you xD | Have you ever fight with logrotate configuration files? Did you survived? Cool, this document is not for you xD | ||
Line 4: | Line 6: | ||
This script write 2 logs each time : | This script write 2 logs each time : | ||
- | $(dirname purge_files.sh)/ | + | * '' |
+ | * '' | ||
+ | So you will have detailed the script actions+errors there | ||
====== Instructions ====== | ====== Instructions ====== | ||
===== Usage ===== | ===== Usage ===== | ||
- | <code bash>/u02/admin/BAVELPRO/ | + | <code bash>/home/scripts/purge_files/ |
===== Configuration ===== | ===== Configuration ===== | ||
+ | It's a file-based configuration, | ||
< | < | ||
- | /u02/admin/BAVELPRO/ | + | CONFIGFILE=/home/scripts/purge_files/ |
</ | </ | ||
+ | |||
==== Config file sytax ==== | ==== Config file sytax ==== | ||
Each line in the config file is set of file to be analysed and purged/ | Each line in the config file is set of file to be analysed and purged/ | ||
Line 47: | Line 53: | ||
==== Sample Config ==== | ==== Sample Config ==== | ||
< | < | ||
- | /home/root/ | + | # Allways purge the script logs |
- | /home/root/ | + | /home/scripts/ |
+ | /home/scripts/ | ||
- | / | + | # Target: nginx logs |
- | / | + | / |
- | / | + | # Objetivo : Oracle listerner trace files |
- | /home/backup/files, | + | /u01/app/oracle/diag/tnslsnr,*trc,bydate,+15,4, |
- | /home/backup/ | + | /u01/app/oracle/diag/tnslsnr,*trm,bydate,+15,4, |
- | /home/backup/mysql, | + | |
- | /home/owncloud/ | + | |
</ | </ | ||
Line 106: | Line 111: | ||
MYDATE=$(date +%Y%m%d%H%M) | MYDATE=$(date +%Y%m%d%H%M) | ||
- | CONFIGFILE=$(dirname $0)/$(basename $0 .sh).config | + | CONFIGFILE=/ |
- | LOGDIR=CONFIG=$(dirname $0)/logs/ | + | LOGDIR=$(dirname $0)/logs/ |
######################################################################## | ######################################################################## | ||
Line 129: | Line 134: | ||
| | ||
PLEASE READ | PLEASE READ | ||
- | https:// | + | https:// |
# VERY INITIAL CHECKS | # VERY INITIAL CHECKS | ||
} | } | ||
Line 150: | Line 155: | ||
[[ " | [[ " | ||
printf " | printf " | ||
- | # workaround for eval " | ||
- | # local AUXDIR="/ | ||
- | # mkdir ${AUXDIR} | ||
- | # cd ${AUXDIR} | ||
eval find ${FOLDER} ${AUX} -name " | eval find ${FOLDER} ${AUX} -name " | ||
- | # cd ${OLDPWD} | ||
- | # rm -fr ${AUXDIR} | ||
} | } | ||
Line 205: | Line 204: | ||
######################################################################## | ######################################################################## | ||
+ | |||
+ | [ ! -d ${LOGDIR} ] && mkdir -p ${LOGDIR} | ||
exec 1>> ${LOGDIR}/ | exec 1>> ${LOGDIR}/ | ||
Line 226: | Line 227: | ||
- | # if [[ ! " | ||
if [[ ! " | if [[ ! " | ||
printf " | printf " | ||
Line 262: | Line 262: | ||
[[ " | [[ " | ||
[[ ! " | [[ ! " | ||
- | find ${FOLDER} ${AUX} -name " | + | find ${FOLDER} ${AUX} -name " |
;; | ;; | ||
* ) | * ) |
linux/purging_script.1381400646.txt.gz · Last modified: 2013/10/10 10:24 by dodger