RSS feed

repair corrupted journal

December 21st, 2008 | Posted in Linux | No Comments

boot from cd – linux rescue

sh-3.1# umount /mnt/sysimage/data
sh-3.1# tune2fs -O ^has_journal /dev/sda6
sh-3.1# e2fsck -y /dev/sda6
sh-3.1# mount -t ext3 /dev/sda6 /mnt/sysimage/data
sh-3.1# rm -f /mnt/sysimage/data/.journal
sh-3.1# umount /mnt/sysimage/var
sh-3.1# tune2fs -j /dev/sda6
sh-3.1# exit

Read More

 



umount: device is busy

December 17th, 2008 | Posted in Linux | No Comments

To see what processes are accessing the disk partition you can use either lsof or fuser.
lsof /tmp
mysqld 13103 mysql 6u REG 8,6 0 12 /tmp/ibisfIna (deleted)
mysqld 13103 mysql [...]

Read More

 



3ware tw_cli

December 16th, 2008 | Posted in Linux | No Comments

7000 and 8000 series 3ware Escaladeā„¢ ATA RAID controllers manual
http://www.3ware.com/support/UserDocs/CLI_UG.pdf
http://www-d0.fnal.gov/~melnit/tw_cli.8.html

Read More

 



PowerDNS with Geo Backend

December 6th, 2008 | Posted in Linux, PowerDNS | 1 Comment

A short guide on how to setup powerdns with the geo and mysql backends to redirect visitors to servers closer to their geographic location.
So how does it work?
We delegate geo.www.domain.com to our powerdns servers that run the geo backend. The backend looks up the IP address of the user’s resolver in a data structure obtained [...]

Read More

 



Sending mail from Perl

December 3rd, 2008 | Posted in Linux, Perl | No Comments

I am using this as a skeleton in various scripts where I need to be notified of errors or successful runs…

#!/usr/bin/perl

open(MAIL,”|/usr/lib/sendmail -t”);

print MAIL “To: you\@domain.com\n”;
print MAIL “From: name \n”;
print MAIL “Subject: your subject\n\n”;
[...]

Read More

 



Speed up your site by caching

December 2nd, 2008 | Posted in Linux | No Comments

Implementing caching on high traffic websites will save you loads of bandwidth and drastically speed up your site loading time for visitors. By using apache modules mod_expires and mod_header you will be able to control exactly what is cached, how long it’s cached for and how proxy servers should behave around your websites.
All static content [...]

Read More

 



sed inline replace/delete

December 2nd, 2008 | Posted in Linux | No Comments

sed -i ’s/foo/bar/’ file(s) or *
or
sed -i ‘/foo/d’ file(s) or *
or
find /path/to/files -type f -name myfile1 -exec sed -i ’s/foo/bar/’ {} \;
or
find /path/to/files -type f -name myfile1 | xargs sed -i ’s/foo/bar/g’

Read More

 



awk quotes

December 2nd, 2008 | Posted in Linux | No Comments

cat file | awk ‘{ print “mysql mydatabase -u ” $3 ” -p”$4″ -h ” $2 ” -e \042SELECT name FROM domains WHERE status = \0470\047\042 >> “$1″.active”}’
echo -e “\047″
\047 being a single quote
\042 being a double quote

Read More

 



unix print ip

November 29th, 2008 | Posted in Linux | No Comments

If you ever needed to get your own IP from shell to use in scripts…

host $(who -m | awk ‘{ print $5 }’ | sed ’s/[()]//g’) | awk ‘{ print $4 }’

Above code is used in a script which updates apache ACL’s with current IP… makes it much easier than manually editing.

Read More

 



grep copy

November 29th, 2008 | Posted in Linux | No Comments

#!/usr/bin/sh
cp `grep -lr ‘STRING’ /dir` /newdir

Read More

 




Categories