Last active
June 12, 2021 22:49
-
-
Save carlos-moreno/6da8e1b71991ad2188e6926dafd68344 to your computer and use it in GitHub Desktop.
Manage the report.sh script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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