IDM log archiver

IDM log archiver

Need to keep your Linux based IDM log files for troubleshooting?

This script zips your log files up, keeping a zip file for each day.



#!/bin/bash
cd $2
if [ -e $1 ] ; then
strFile=`date +%d%m%y`
myHost=`hostname`
strFile=$strFile"-"$myHost".zip"
# echo $strFile
strTime=`date +%H%M%S`
# echo $strTime
mv $1 $strTime$1
zip $strFile -q -9 -o -m $strTime$1
else
echo "file not found"
fi




Simply call the script passing the name of the log file you wish to archive and the path to your log files as command line parameters.

You can run this in your crontab, calling it every minute (or whatever period suites you) When the log file rolls over the _1.log file will be renamed with a time stamp and added to todays zip file. If the log file has not yet rolled the script just exits.

Example:

log_archiver.sh Driver1_1.log /IDMLOGS/

Enjoy!

Cheers

Jim
Labels (2)
Tags (1)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Comments
what a great script, so usefull for keeping track of all the driver traffic, so easy to keep these rolled up files in a central location for auditing and legal purposes.
Most excellent, would be great if this replaced invalid windows chars in the renamed log name.
Top Contributors
Version history
Revision #:
6 of 6
Last update:
‎2020-03-10 19:25
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.