(Script) db2 force applications for a database

$ cat db_force.sh
#!/bin/bash
##This script takes database name as argument
##and displays db2 force application commands for given database
##You don’t have to run “Force application All” just to
##terminate a specific database connections.

if [ “$#” -ne “1” ]
then
echo “USAGE:$0  <Database Name>”
exit;
fi
#DBNAME=`echo $1 | tr a-z A-Z`
db2 list applications | awk -v DBNAME=`echo $1 | tr a-z A-Z` -F” ” ‘{if ($5 == DBNAME) print “db2 \”force application(“,$3,”)\”” }’
if [ “$?” -ne “0” ]
then
echo “Exit code is: Failure”
exit
fi

Alternatively, the script can be downloadable from below link:

db_force.sh

 
Example usage of script:
************************

db_force_screenshot1

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: