Posts

Showing posts from May, 2012

Shell Script to remove files recursively from a folder

Shell Script to remove files recursively from a folder with 10 minutes each: When we were running a Load test or stability test, one of the transaction creates files in a directory. These files need to be deleted when ran for long runs. In Linux: fdir="<path>/App_domain/attachments/lit/*" while [ true ] do find $fdir -cmin +10 -type f -exec rm -rf {} \; sleep 500 done when tried the above on solaris, it failed as -cmin is not supported in Solaris. Only options supported are -atime, -ctime and -mtime. but these works on hours and not on minutes. Modified the script to run in solaris: fdir="<path>/App_domain/attachments/lit/*" while [ true ] do touch somefile sleep 5 find $fdir ! -newer somefile -exec rm -rf {} \; sleep 500 done

Using gdb to analyse core dumps in Linux

Once core file is generated. Steps to analyze the core dump file- Run “gdb /usr/java/jdk1.6.0_24/bin/java (java path) core.11151 (core file)” You will get the gdb prompt Type “bt” for stack trace. To switch the thread, type “thread [thread no]” To check the stack trace for selected thread again type “bt” To get the stack of all the thread run “thread apply all bt full” Find “LowMemoryDetector::low_memory_detector_thread_entry” in stack trace. To find exactly in which thread it occured, type "where" Example of "where" output: where #0  0xffffe410 in __kernel_vsyscall () #1  0x00b0ddf0 in raise () from /lib/libc.so.6 #2  0x00b0f701 in abort () from /lib/libc.so.6 #3  0xf78e123f in os::abort(bool) () from /usr/java/jdk1.6.0_24/jre/lib/i386/server/libjvm.so #4  0xf7a28431 in VMError::report_and_die() () from /usr/java/jdk1.6.0_24/jre/lib/i386/server/libjvm.so #5  0xf7a28fe1 in crash_handler(int, siginfo*, void*) () from /usr/java/jdk1.6.0_24/jre/li...