Tuesday, June 7, 2011
Monday, May 30, 2011
Macro for excel to run Putty from Excel sheet with the Server name
Sub PUTTY()
Shell "C:\Putty.exe -ssh " & activecell
End Sub
Shell "C:\Putty.exe -ssh " & activecell
End Sub
Sunday, May 29, 2011
Log Rotation Script
Simple Log rotation
#!/bin/bash
F1=/apps/apache/logs/access_log
F2=/apps/apache/logs/error_log
F3=/apps/apache/logs/server1.log
timestamp=`date +%Y%m%d`
for i in $F1 $F2 $F3
do
newlogfile=$i.$timestamp
/bin/cp $i $newlogfile
> $i
/usr/bin/gzip $newlogfile
done
Log rotation based on File size
#!/bin/bash
F1=/apps/apache/logs/access_log
F2=/apps/apache/logs/error_log
F3=/apps/apache/logs/server1.log
timestamp=`date +%Y%m%d`
for i in $F1 $F2 $F3
do
logfile=`ls -ltr $i | awk {' print $5'}`
newlogfile=$i.$timestamp
if [ $logfile -gt 5000000 ]; then
/bin/cp $i $newlogfile
> $i
/usr/bin/gzip $newlogfile
fi
done
One more New
#!/bin/bash
timestamp=`date '+%m%d%Y_%H'`
serverlogloc=/apps/symc/domains/crs/servers
for i in `ls -l $serverlogloc| grep '^d'|awk '{print $9}'|grep -v domain_bak`
do
if [ -f $serverlogloc/$i/logs/$i.out ]
then
size=`ls -l $serverlogloc/$i/logs/$i.out | awk '{print $5}'`
if [[ $size -gt 5120000 ]]
then
newlogfile=$serverlogloc/$i/logs/$i.out.$timestamp
cp -p $serverlogloc/$i/logs/$i.out $newlogfile
> $serverlogloc/$i/logs/$i.out
fi
fi
done
#!/bin/bash
F1=/apps/apache/logs/access_log
F2=/apps/apache/logs/error_log
F3=/apps/apache/logs/server1.log
timestamp=`date +%Y%m%d`
for i in $F1 $F2 $F3
do
newlogfile=$i.$timestamp
/bin/cp $i $newlogfile
> $i
/usr/bin/gzip $newlogfile
done
Log rotation based on File size
#!/bin/bash
F1=/apps/apache/logs/access_log
F2=/apps/apache/logs/error_log
F3=/apps/apache/logs/server1.log
timestamp=`date +%Y%m%d`
for i in $F1 $F2 $F3
do
logfile=`ls -ltr $i | awk {' print $5'}`
newlogfile=$i.$timestamp
if [ $logfile -gt 5000000 ]; then
/bin/cp $i $newlogfile
> $i
/usr/bin/gzip $newlogfile
fi
done
One more New
#!/bin/bash
timestamp=`date '+%m%d%Y_%H'`
serverlogloc=/apps/symc/domains/crs/servers
for i in `ls -l $serverlogloc| grep '^d'|awk '{print $9}'|grep -v domain_bak`
do
if [ -f $serverlogloc/$i/logs/$i.out ]
then
size=`ls -l $serverlogloc/$i/logs/$i.out | awk '{print $5}'`
if [[ $size -gt 5120000 ]]
then
newlogfile=$serverlogloc/$i/logs/$i.out.$timestamp
cp -p $serverlogloc/$i/logs/$i.out $newlogfile
> $serverlogloc/$i/logs/$i.out
fi
fi
done
Subscribe to:
Comments (Atom)