Introduction
The Data Agent generates logs every day and over time this can cause a disk space issue if not properly managed.
The following Linux script was developed to automatically compress log files older than 7 days and delete archived logs older than 30 days.
Steps needed
- Uncompress the attached script on the DataAgent server
- Change the file to have execute permission using this Linux command:
chmod 744 ArchiveDALogs.sh
- Edit the file using vi
- Edit the variable FULL_LOG_PATH to set the full path to the logs folder like the example below:
FULL_LOG_PATH="/incorta/DataAgent/logs"
- If you need to edit the number of days being compressed you can edit the number 7 in the second line, if you need to edit the number of days until the deletion of the compressed logs, you can edit the number 30 in the 3rd line.
- Add a cronjob to run this every day by typing:
crontab -e
- Add the following line to have a corn job running everyday at 1 AM.
0 1 * * * full_path_to_ArchiveDALogs.sh > 2>&1