Sh3ll



Directory :  /scripts2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Current File : //scripts2/large_databases-report.sh
#!/bin/bash

###############################################################################
# Large MySQL Report
#
# Busca archivos de bases de datos mayores al umbral configurado.
# Genera un reporte simple:
# archivo|bytes
###############################################################################

set -o nounset
set -o pipefail

############################
# Configuración
############################

THRESHOLD=2147483648     # ~2 GB

REPORT="/etc/sitioshispanos/large_mysql_report.txt"

############################
# Inicialización
############################

mkdir -p "$(dirname "$REPORT")"

: > "$REPORT"

############################
# Procesamiento
############################

find /var/lib/mysql \
    -maxdepth 2 \
    -type f \
    -size +$((THRESHOLD / 1024 / 1024))k \
    -print0 |
while IFS= read -r -d '' archivo; do

    size=$(stat -c%s "$archivo") || continue

    (( size > THRESHOLD )) || continue

    printf '%s|%d\n' \
        "$archivo" \
        "$size" >> "$REPORT"

done

exit 0

Sh3LL