Skip to content

Instantly share code, notes, and snippets.

@carlos-moreno
Last active June 12, 2021 22:49
Show Gist options
  • Save carlos-moreno/6da8e1b71991ad2188e6926dafd68344 to your computer and use it in GitHub Desktop.
Save carlos-moreno/6da8e1b71991ad2188e6926dafd68344 to your computer and use it in GitHub Desktop.
Manage the report.sh script
#!/bin/bash
######################## INFORMACOES DO SCRIPT #########################################################################
# Nome: report_manager.sh #
# Objetivo: Gerenciar a execucao do script "report.sh", excluindo arquivos criados a +X dias e compactando os arquivos #
# restantes do diretorio de trabalho. #
# Requisitos: Para rodar o script com sucesso e necessario ter o script "report.sh" #
# Criado por: Carlos Augusto Moreno Ribeiro Junior #
# Versão: 0.1 #
########################################################################################################################
WORKDIR=/opt/Report/
NAME_FILE=report_$(date +%Y%m%d%H%M%S).txt
if ! [ -d $WORKDIR ];
then
mkdir -p $WORKDIR
fi
# Find and remove old files the report
find $WORKDIR -name "*.gz" -mtime +14 -exec rm {} \;
# Compress old files
find $WORKDIR -name "*.txt" -exec gzip {} \;
# Generate new report the server
bash report.sh > $WORKDIR$NAME_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment