Wednesday, October 26, 2011
Set Date In Ubantu
1 . Set Timezone
2. sudo date --set="26 OCT 2011 19:51:00"
3 You can sync the Hw clock aswell : hwclock -w
Tuesday, August 30, 2011
Tomcat Remote Debug in linux
add folowing inside /etc/default/tomcat6
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
and restart . tomcat debug is now in port 8787
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
and restart . tomcat debug is now in port 8787
Monday, August 22, 2011
Wednesday, August 17, 2011
Thursday, July 7, 2011
Archive logs and Restart tomcat script .
#!/bin/bash
#author sanjeewa
#Important!! Script Must be run as root(u can ignore this if your tomcat does not need root
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export PATH
NOW=$(date +"%Y%m-%dT%H%M")
LOG_PATH=/home/abc/logs
log1=/var/log/tomcat6/catalina.out
log2=/var/log/tomcat6/application/error.log
log3=/var/log/tomcat6/application/application.log
netstatlog=/home/abc/logs/netstat.log
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo `date` ":Tomcat restart script initiated!!"
cd $LOG_PATH
touch $netstatlog
echo "" > $netstatlog
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -gt 0 ];
then
echo "tomcat found running"
netstat --tcp > $netstatlog
kill -3 `ps ax | grep tomcat6 | grep -v grep | awk '{print $1}'`
/etc/init.d/tomcat6 stop
/etc/init.d/tomcat6 stop
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -gt 0 ];
then
kill -9 `ps ax | grep tomcat6 | grep -v grep | awk '{print $1}'`
fi
tar -cvf $NOW-abc.tomcat.tar $log1 $log2 $log3 $netstatlog
rm $log1
rm $log2
rm $log3
echo "Restarting tomcat !!!!!"
/etc/init.d/tomcat6 start
else
echo "Tomcat not found running"
echo "Restarting tomcat !!!!!"
/etc/init.d/tomcat6 start
fi
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -eq 0 ];
then
/etc/init.d/tomcat6 start
fi
#you may use same script for search a exception in logs , if found restart
#[ `grep -R "ABC exception try restarting transaction" $log1 | egrep -v egrep | wc #-l` -gt 0 ];
#author sanjeewa
#Important!! Script Must be run as root(u can ignore this if your tomcat does not need root
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export PATH
NOW=$(date +"%Y%m-%dT%H%M")
LOG_PATH=/home/abc/logs
log1=/var/log/tomcat6/catalina.out
log2=/var/log/tomcat6/application/error.log
log3=/var/log/tomcat6/application/application.log
netstatlog=/home/abc/logs/netstat.log
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo `date` ":Tomcat restart script initiated!!"
cd $LOG_PATH
touch $netstatlog
echo "" > $netstatlog
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -gt 0 ];
then
echo "tomcat found running"
netstat --tcp > $netstatlog
kill -3 `ps ax | grep tomcat6 | grep -v grep | awk '{print $1}'`
/etc/init.d/tomcat6 stop
/etc/init.d/tomcat6 stop
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -gt 0 ];
then
kill -9 `ps ax | grep tomcat6 | grep -v grep | awk '{print $1}'`
fi
tar -cvf $NOW-abc.tomcat.tar $log1 $log2 $log3 $netstatlog
rm $log1
rm $log2
rm $log3
echo "Restarting tomcat !!!!!"
/etc/init.d/tomcat6 start
else
echo "Tomcat not found running"
echo "Restarting tomcat !!!!!"
/etc/init.d/tomcat6 start
fi
if [ `ps -ef | egrep 'tomcat6' | egrep -v egrep | wc -l` -eq 0 ];
then
/etc/init.d/tomcat6 start
fi
#you may use same script for search a exception in logs , if found restart
#[ `grep -R "ABC exception try restarting transaction" $log1 | egrep -v egrep | wc #-l` -gt 0 ];
Thursday, June 2, 2011
Script to restart a remote machine, if certain processers found running.
Eg : Usage can be change to any command (eg : shutdon, sending mails, backup ..)
#!/bin/bash
# author SanjeewaF.
# Script will reastrt the remote server if any matching processors found.
# Process 1 : [abc]
if [ ! $1 ] ; then
echo "Please specify the remote IP";
exit
fi
echo "Checking for xyz Processers ========================== ";
ssh root@$1 "if [ `ps -ef | egrep '(\[\babc\b]
Tuesday, March 15, 2011
Shell script to travel through Mysql database tables
TABLES=$($MYSQL -u $MUSER -p$MPASS $MDB -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables' )
for t in $TABLES
do
echo "checking $t table from $MDB database..."
$MYSQL -u $MUSER -p$MPASS $MDB -e "check table $t"
done
I found it in Net .. might be useful ..
for t in $TABLES
do
echo "checking $t table from $MDB database..."
$MYSQL -u $MUSER -p$MPASS $MDB -e "check table $t"
done
I found it in Net .. might be useful ..
Subscribe to:
Posts (Atom)