- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to kill session
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2008 08:21 PM
тАО07-16-2008 08:21 PM
Please help me with this script.
i am trying to write a script to terminate locking sessions and it run from cron every 5 mins.
if column 6 and 7 are 6 and 6 using AWK to get value in column 1 and 2 and then insert it into sql statement "alter session....."
if no line is returned then exist.
#!/usr/bin/sh
export NLS_LANG=AMERICAN_AMERICA.UTF8
/u10/app/oracle/product/db10g/bin/sqlplus / as sysdba <
EOF
grep 6 /home/oracle/ORACLE/CHK/wlm.log|awk '{if ($6==6 && $7==6) print}'
if no line return exist (Please help on this syntax)
##if column 6 and 7 of file wlm.log are 6 and 6 then
else
awk '{print $1 " " $2}'
250 13233
251 13233
--Do you know away to insert 2 results back to this sql statement
/u10/app/oracle/product/db10g/bin/sqlplus / as sysdba <
/home/oracle/ORACLE/CHK/locktest.sql
this is the result of locktest.sql
wlm.log
SID SERIAL# TY ID1 ID2 LMODE REQ
----- ---------- -- --------- --------- ------
764 1 TS 3 1 3 0
250 13233 TM 79026 0 3 0
250 13233 TX 196627 3532464 6 0
250 13233 TX 196627 3532464 6 6
251 13233 TX 196627 353246 6 6
Thanks in advance,
Tom
Solved! Go to Solution.
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2008 09:58 PM
тАО07-16-2008 09:58 PM
Re: Script to kill session
>Do you know away to insert 2 results back to this sql statement
Try this:
awk '
($6==6 && $7==6) {
printf "ALTER SYSTEM KILL SESSION '%s,%s' ;\n", $1, $2
}' /home/oracle/ORACLE/CHK/wlm.log > sql.cmd
if [ ! -s sql.cmd ]; then
exit
fi
/u10/app/oracle/product/db10g/bin/sqlplus / as sysdba < sql.cmd
I'm not sure of the exact format in SQL. Did you want a "&" before the numbers?
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2008 10:26 PM
тАО07-16-2008 10:26 PM
Re: Script to kill session
Thanks Dennis,
Try this:
awk '
($6==6 && $7==6) {
printf "ALTER SYSTEM KILL SESSION '%s,%s' ;\n", $1, $2
}' /home/oracle/ORACLE/CHK/wlm.log > sql.sql
if [ ! -s sql.sql ]; then
exit
fi
/u10/app/oracle/product/db10g/bin/sqlplus / as sysdba <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2008 10:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-16-2008 11:12 PM
тАО07-16-2008 11:12 PM
Re: Script to kill session
I test the whole script and it works well.
Thank you very much,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2008 07:52 AM
тАО07-21-2008 07:52 AM