Baanboard.com

Go Back   Baanboard.com > Blogs > patvdv's blog

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

 
Save Baan Archive Logs
By patvdv at 4 Apr 2006 - 20:08

Introduction

Here's a very simple script to rotate your $BSE/log/olg files into $BSE/olg. The script has been greatly simplified to make it more generic.

Possible suggestions to enhance the script:

  • (error) logging
  • introduce support for multiple $BSE
  • archive only specific type of log files (e.g. log.oracle7/8 etc)

 

Script

#!/usr/bin/ksh
#******************************************************************************
#* Title : save_baan_logs.ksh - The Program Title
#* Description: : archive Baan olg.* and big log files
#* Author : Patrick Van der Veken
#* Date : 19-dec-2001
#******************************************************************************
#* Category : Application
#* Platform : most UNIX variants I suspect
#*
#* License :
#* Copyright 2001 by Patrick Van der Veken
#
#* All Rights Reserved
#*
#* Permission to use, copy, modify, and distribute this software and its
#* documentation for any purpose and without fee is hereby granted,
#* provided that the above copyright notice appear in all copies and that
#* both that copyright notice and this permission notice appear in
#* supporting documentation.
#*
#* Patrick Van der Veken and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD
#* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
#* AND FITNESS, IN NO EVENT SHALL Patrick Van der Veken nor Baanboard.com BE
#* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
#* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
#* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
#* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
#* OR PERFORMANCE OF THIS SOFTWARE.
#******************************************************************************

# Customizable data structures
# put here your required environment variables
BSE=/opt/baan4
BSE_LOG_DIR=${BSE}/log
BSE_OLG_DIR=${BSE}/olg
OLG_LIST_FILE=/tmp/olglist.$$
BIGLOG_LIST_FILE=/tmp/bigloglist.$$

# Script data structures
SCRIPT_NAME=$(basename $0)
CURRENT_DATE=$(date +%Y%m%d-%H%M)


# Subroutines

display_usage()
{
echo "\n*** ${SCRIPT_NAME} by Patrick Van der Veken - Baanboard.com"
echo "* This script will rotate Baan log files:"
echo "* a. olg.* files"
echo "* b. log files > 1MB"
echo "These files are archived and compressed into a separate directory"
echo "Usage:"
echo "-show_help | -?: show this help text"
echo "no arguments: run script normally\n"
return 0
}

pre_checks()
{
# put here all actions that need to be performed
# before the main routine runs
cat /dev/null >${OLG_LIST_FILE}
cat /dev/null >${BIGLOG_LIST_FILE}
if [ ! -d ${BSE_OLG_DIR} ]
then
mkdir ${BSE_OLG_DIR}
chown bsp:bsp ${BSE_OLG_DIR}
chmod 700 ${BSE_OLG_DIR}
fi
}

get_olg_files()
# get list of 'olg' files
{
ls -1 ${BSE_LOG_DIR}/olg.* | awk 'BEGIN { FS = "/" } { print $(NF) }' >${OLG_LIST_FILE} 2>/dev/null
}

archive_olg_files()
# archive OLG files
{
while read OLG_FILE_NAME
do
NEW_OLG_FILE_NAME="${OLG_FILE_NAME}.[${CURRENT_DATE}]"
mv -f ${BSE_LOG_DIR}/${OLG_FILE_NAME} ${BSE_OLG_DIR}/${NEW_OLG_FILE_NAME}
compress ${BSE_OLG_DIR}/${NEW_OLG_FILE_NAME}
done <${OLG_LIST_FILE}
}

get_biglog_files()
# get other log files >1MB
{
find ${BSE_LOG_DIR}/. -size +1000000c -print | awk 'BEGIN { FS = "/" } { print $(NF) }' >${BIGLOG_LIST_FILE} 2>/dev/null
}

archive_biglog_files()
# archive other BIG log files >1MB
{
while read BIGLOG_FILE_NAME
do
NEW_BIGLOG_FILE_NAME="${BIGLOG_FILE_NAME}.[${CURRENT_DATE}]"
mv -f ${BSE_LOG_DIR}/${BIGLOG_FILE_NAME} ${BSE_OLG_DIR}/${NEW_BIGLOG_FILE_NAME}
compress ${BSE_OLG_DIR}/${NEW_BIGLOG_FILE_NAME}
done <${BIGLOG_LIST_FILE}
}

post_checks()
{
# put here all actions that need to be performed
# after the main routine has been run
chown -R bsp:bsp ${BSE_OLG_DIR}
chmod -R 640 ${BSE_OLG_DIR}
chmod 750 ${BSE_OLG_DIR}
rm -f ${OLG_LIST_FILE}
rm -f ${BIGLOG_LIST_FILE}
}


# Main Routine

if [ $# -gt 0 ]
then
for PARAMETER in $*
do
case ${PARAMETER} in
-show_help|-\?) display_usage && exit 0;;
esac
done
echo "<!> Wrong argument. Use '-show_help' or '-?' only"
exit 0
fi

# pre-checks
pre_checks

ls -1 ${BSE_LOG_DIR}/olg.* >/dev/null 2>&1
if [ $? -eq 0 ]
then
get_olg_files
archive_olg_files
fi
TOTAL_FINDS=$(find ${BSE_LOG_DIR}/. -size +1000000c -print | wc -l)
if [ $TOTAL_FINDS -ne 0 ]
then
get_biglog_files
archive_biglog_files
fi

# post-checks
post_checks

exit 0

Requirements

  • OS: *nix, KSH88
  • Application: BaanIV, BaanV

0
No votes yet


All times are GMT +2. The time now is 15:53.


©2001-2017 - Baanboard.com - Baanforums.com