sample wrapper shell scripts for Unix newbie

Post date: Dec 04, 2014 6:12:51 PM

#!/bin/bash

##############################################################################################################################

#script name:sample_wrapper_script.sh

#Description: This script will analyze the tables in test schema.

#Version: 1.0

#date created: 12/04/2014

#date updated:

#reason for update:

##usage: nohup ./sample_wrapper_script.sh 2>&1 &

#dependency: analyze.sql

#Bug reports and enhancements: Contact us at gpdba@greenplumdba.com

###############################################################################################################################

starttime=$(date +\%F_\%H:\%M)

dbname="prod"

scriptname="sample_wrapper_script"

logfile=${scriptname}_ouput_$starttime.log

touch $logfile

printf "\n#######################################################################################################################\n">>$logfile

printf "Script started at %s\n" "$starttime">>$logfile

printf "For bug fixes and enhancements, contact Sachi at gpdba@greenplumdba.com\n">>$logfile

printf "########################################################################################################################\n">>$logfile

debugflag="e"

echo "Script is running.Please wait.It may take few minutes..."

printf "ANALYZE started on IPM tables\n">>$logfile

psql -$debugflag -d $dbname -f analyze.sql

endtime=$(date +\%F_\%H:\%M)

printf "\n#######################################################################################################################\n">>$logfile

printf "Script completed at %s\n" "$endtime" >>$logfile

printf "\n#######################################################################################################################\n">>$logfile

####################################################################################################

# End of sample_wrapper_script.sh

####################################################################################################

echo "Script completed. Script log file is available. Log file name:$logfile "