IHS: Cleanup script for mod cache
If you are using mod_cache/mod_disk_cache to use disk cache on Apache/IBM HTTP Server, you must run htcacheclean to cleanup cache to not be out of space.
htcacheclen takes too much time to run. So i create a script that run htcacheclean against sub-directories, this way the command run faster.
Procedure
1) Create a file cleancache.sh, and put the following content:
#!/bin/bash APACHE_BIN_DIR=/opt/IBM/HTTPServer/bin LOGFILE=/var/log/httpd/cleancache.log CACHE_FILES=var/cache/mod_disk_cache # Cache Size in GB SIZE=2; echo "############################################" > $LOGFILE NOW=$(date +"%Y-%m-%d-%H-%M-%S") echo "[$NOW] Start Cleanup Cache" >> $LOGFILE echo "" >> $LOGFILE echo "############################################" >> $LOGFILE df -g >> $LOGFILE echo "############################################" >> $LOGFILE df >> $LOGFILE echo "############################################" >> $LOGFILE # We must divide SIZE by the number of directories (4096), # to get the per-directory limit, in megabytes LIMIT=$(( $SIZE * 1024 * 1024 / 4096 ))K; for i in $CACHE_FILES/*; do NOW=$(date +"%Y-%m-%d-%H-%M-%S") echo "[$NOW] Diretorio $i" >> $LOGFILE #du -sm $i >> $LOGFILE $APACHE_BIN_DIR/htcacheclean -v -t -p$i -l$LIMIT >> $LOGFILE 2>&1 #du -sm $i >> $LOGFILE echo "" >> $LOGFILE done; echo "" >> $LOGFILE echo "############################################" >> $LOGFILE df -g >> $LOGFILE echo "############################################" >> $LOGFILE df >> $LOGFILE echo "############################################" >> $LOGFILE NOW=$(date +"%Y-%m-%d-%H-%M-%S") echo "[$NOW] End of Cleanup Cache" >> $LOGFILE
Save and close
2) Change permission
chmod a+x cleancache.sh
3) Putting on Cron:
Edit crontab using crontab -e
Add the following lines
###### Script de Limpeza do Cache do IBM HTTP Server###### 0 4 * * 6 /opt/IBM/HTTPServer/bin/cleancache.sh
Ver também
- Definindo a URL padrão no IBM HTTP Server Apache
- Apache:Redirecionando para pagina de Erro
- Apache:Redirecionando de HTTP para HTTPS
- Linux e Unix: Ferramentas de Monitoracao e Performance
- AWSTATS: Configurando o AWSTATS