R12.2 Apps DBA. Powered by Blogger.

Unix command Useful for Oracle DBA

No comments :
How to kill all similar processes with single command (in this case java)
ps -ef | grep java |grep -v grep | awk ‘{print $2}’ |xargs -i kill -9 {}
Locating Files under a particular directory
find . -print |grep -i xyz.sql
Cleanup any unwanted trace files more than seven days old
find . *.trc -mtime +7 -exec rm {} ;
To remove a specific column of output from a UNIX command – for example to determine the UNIX process Ids for all Oracle processes on server (second column)
ps -ef |grep -i oracle |awk ‘{ print $2 }’
Changing the standard prompt for Oracle Users
Edit the .profile for the oracle user
PS1=”`hostname`*$ORACLE_SID:$PWD>”
Display top 10 CPU consumers using the ps command
/usr/ucb/ps auxgw | head -11
Show number of active Oracle dedicated connection users for a particular ORACLE_SID
ps -ef | grep $ORACLE_SID|grep -v grep|grep -v ora_|wc -l
Display the number of CPU’s in Solaris
psrinfo -v | grep “Status of processor”|wc -l
How to schedule a Job in Unix
Use cronjob
crontab -l ( list current jobs in cron)
crontab -e ( edit current jobs in cron )
_1_ _2_ _3_ _4_ _5_ $Job_Name
1 – Minutes (0-59)
2 – Hours ( 0-24)
3 – day of month ( 1- 31 )
4 – Month ( 1-12)
5 – A day of week ( 0- 6 ) 0 -> sunday 1-> monday
e.g. 0 0 1 * 5 Means run job at Midnight on 1st of month & every friday
Crontab examples
To submit a task every Tuesday (day 2) at 2:45PM
45 14 2 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
To submit a task to run every 15 minutes on weekdays (days 1-5)
15,30,45 * 1-5 * * /opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
To submit a task to run every hour at 15 minutes past the hour on weekends (days 6 and 0)
15 * 0,6 * * opt/oracle/scripts/tr_listener.sh > /dev/null 2>&1
Show all links
find . -type l -exec ls -ld {} ;
show all directiries
find . -type d -exec ls -ld {} ;
How to find the release in Linux
cat /etc/*-release
To print the top 10 largest “files and directories”:
$ du -a . | sort -nr | head
To print the top 10 largest files names (not directories) in a particular directory and its sub directories
$ find . -printf ‘%s %p\n’|sort -nr|head
To restrict the search to the present directory use “-maxdepth 1” with find.
$ find . -maxdepth 1 -printf ‘%s %p\n’|sort -nr|head
How to check if a Port is listening for any Service
netstat -an | grep <port no>
How to find the symbolic links that point to the old path in your oracle_home and appl_top.
ls -al `find . -type l` | grep $OLD_PATH
To find CPU in Solaris
uname -X
To find files modified in the last  n mins:
find . -mmin -n
To find files modified before n mins:
find . -mmin +n
How To Check Environment Variables for a Running Process
In Linux,
strings –a /proc/<pid_of_the_process>/environ
In Solaris,
pargs -e <pid_of_the_process>
In AIX,
pargs or ps eww <pid_of_the_process>
Display n lines after match
grep -A <n> “string” FILENAME
Display N lines before match
grep -B <n> “string” FILENAME
Searching in all files recursively using grep -r
grep -r “tom” *
Eliminate empty and commented lines
sed -e ‘s/#.*//;/^$/d’ filename.txt
Eliminate Comments Using sed
sed -e ‘s/#.*//’ filename.txt
Display One File Per Line Using ls -1
ls -1
Display File Size in Human Readable Format Using ls -lh
$ ls -lh

No comments :

Post a Comment

Note: only a member of this blog may post a comment.