update_db_inputs.conf

时间:2023-03-08 19:22:51

#!/bin/bash
#-------------------------------------------------------------------------------
# Name: update_db_inputs.sh
#
# Purpose: Database connection profile change,
# Change the connection database name to the previous day
#
# Author: SYNTEK-LIDS
#
# Created: 2019-4-18 Version: 1
#
# Updated: 2019-4-18
#-------------------------------------------------------------------------------

#Related Information
dir=/opt/splunk/etc/apps/splunk_app_db_connect/local
config_file=$dir/db_inputs.conf
log_file=$dir/update_db_inputs_history.log
pre_day=$(date +%Y%m%d -d -1days)

#Log, write history configuration data
echo "################ change config file at $(date +%F-%T) #######################" >>$log_file
cat $config_file >>$log_file

#Replace configuration file
sed -i "s/[0-9]\{8\}/$pre_day/g" $config_file

#Write completion log
echo "################ completion at $(date +%F-%T) #######################" >>$log_file