Created
December 11, 2013 18:16
-
-
Save devjason/7915595 to your computer and use it in GitHub Desktop.
Script suitable for cron to check Oracle password expiration status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Displays Oracle user password expiration status and date. | |
# Open but expired date users have not logged in since they expired. | |
# Where filter currently commented out, use as desired. | |
# Source: http://oraclespin.wordpress.com/2008/01/30/check-oracle-password-for-expiration/ | |
TOADDR=someone@example.com | |
REPORT=`mktemp` | |
TODAY=`date +%F` | |
sqlplus -S / as sysdba <<EOF > $REPORT | |
set linesize 200 | |
set pagesize 500 | |
column "EXPIRE DATE" format a20 | |
select | |
username as "USER NAME", | |
expiry_date as "EXPIRE DATE", | |
account_status | |
from | |
dba_users | |
-- where | |
-- expiry_date < sysdate+120 | |
-- and account_status IN ( "OPEN", "EXPIRED(GRACE)" ) | |
order by | |
account_status, expiry_date, username | |
/ | |
EOF | |
mail -s "Oracle Password Status: $TODAY" $TOADDR < $REPORT | |
rm $REPORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it work for anyone?