Sitemap |
You are here: Home
> Tips and Tricks
> Useful UNIX commands for DBA's
UNIX Commands for Database Administrators This personal notepad of a DBA shared with others contains some useful UNIX commands for DBA's who don't use those commands on a daily base. Professional UNIX-administrator will not find here anything what they not know.
:1,$s/string1/string2/gvi search and replacemv x.txt x.txt `date '+txt.%y_%m_%d'`add a timestamp to a file.
Use a loop to execute tkprof for many trace filesAfter tracing database sessions you find .trc files in the user dump destination.The following UNIX-command executes "tkprof" for all trace files in this directory and adds the extension ".txt" to output files. for p_file in `ls *.trc`; do tkprof $p_file $p_file.txt explain=<username>/<password>; doneWarning: If you have many trace file (.trc) in this directory, the execution of the loop for all can cause high server load and might cause this filesystem to run full. Advise: Check how many trace files you have and replase the "ls *.trc" with a more selective condition! Loop that sleeps 5 secondswhile true do date echo 'Hallo' sleep 5 done MemoryDisplay Process Memory in MB and sortps -efl |awk '{print "MB " $10*8/1024 " " $16}' |sort -n -k 2,2Note: This command assumes that "ps -efl" displays the memory consumption in 8 KB pages. Note: On Solaris the Shared Memory (e.g. Oracle SGA) is included. To see the real memory consumption the shared memory needs to be substracted. /opt/RMCmem/bin/prtmem Where is my memory? - Excellent answer from Sunmanagers MailinglistCheck "Question 1 - Where is all my Memory?" in http://www.sunmanagers.org/archives/1997/att-1736/01-kernel.txtCleanup of IPC segmentsReference to another website: http://ocpdba.net/oracle/ipcs_cleanup.htmlSearching core files and empty filesHow to find core filesSearching just for the name "core" might find files which are not real "core" files created by core-dumps but unfortunately use this name. Real files from core dumps can be identified by the file argument using the "xargs" command:$ find . -type f -name core |xargs file ./scripts/core: ELF 32-bit MSB core file SPARC Version 1, from 'oraweb'The example above is not the final solution, it just shows the working principle. To display just the filename we need to "cut" the first field (-f1) and remove the delimiter ":" (-d:) find . -type f -name core |xargs file | grep "core file" |cut -f1 -d:Example output: ./scripts/core Searching empty filesfind . -size 0c moving empty files to other directory
find . -size 0c -exec mv{} /destination_directory \;&
Config Files ....
|