Writing by shivdev on Friday, 6 of May , 2011 at 9:43 pm
Got deadlock?
killall -QUIT java
This will log the thread dumps for your java processes wherever the processes standard output is configured.
Category: Java,Linux
Writing by shivdev on Friday, 6 of May , 2011 at 7:35 am
If you want to delete a PATTERN from a Log File.
$ sed ‘/PATTERN/d’ server.log > newServer.log
If you want to write a small script to do it:
#!/bin/sh
files="/home/user/app/logs/*.log"
for f in $files
do
sed '/PATTERN/d' $f > $f.out
mv $f.out $f
done
Now if you want to do it for a bunch of log files, I wrote a script that works for me:
#!/bin/sh
# Check usage
if [ $# -lt 2 ] ; then
echo "Syntax: $0 <DeleteString> <Directory/Pattern>"
echo "Example: $0 DefaultRequestDestination ./logs/*webser*.log*"
exit 1
fi
PATTERN=$1
shift
# Print Warning Info: About to mess with your logs
for f in $@
do
echo "Will Delete Lines Containing: $PATTERN in file: $f"
done
read -p "Are you sure? " -n 1
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "OK Cleaning... "
# Loop over files pattern
files=$@
for f in $files
do
echo "Cleaning: $f"
sed "/"${PATTERN}"/d" $f > $f.out
mv $f.out $f
done
fi
Category: Linux