Friday, March 26, 2021

get list of user accounts - either unlocked or password is expired.

 

SELECT    

     'ALTER '||

     SUBSTR(DBMS_LOB.SUBSTR(DBMS_METADATA.GET_DDL('USER',USERNAME),

     INSTR(DBMS_LOB.SUBSTR(DBMS_METADATA.GET_DDL('USER',USERNAME),500),'DEFAULT')-1) ,

     INSTR(DBMS_LOB.SUBSTR(DBMS_METADATA.GET_DDL('USER',USERNAME),500),'USER')) USER_PASS , USERNAME, PROFILE 

FROM  DBA_USERS 

WHERE USERNAME IN 

     (SELECT USERNAME  

      FROM DBA_USERS 

      WHERE (USERNAME  in

            (select username  from dba_users where (account_status like '%EXPIRED%' or account_status like '%LOCK%'))));

Wednesday, February 24, 2021

search a pattern in file using Python

 import re

pattern = re.compile("ORA-")

for line in open("x2.txt"):

    for match in re.finditer(pattern, line):

        print(line)


count number of files generated per day

 # count number of files generated per day

find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c


# count number of files generated per hour in last 600 minutes

find . -cmin -600  -type f -printf '%TY-%Tm-%Td-%TH\n' | sort | uniq -c


find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val]   }'|sort