To delete empty directory
for d in `find /www/xxxx/oldfiles/* -type d -mtime +1| sort -r`;do echo $d;rmdir $d;done
To delete empty directory
for d in `find /www/xxxx/oldfiles/* -type d -mtime +1| sort -r`;do echo $d;rmdir $d;done
Some cron didn’t work well after move to CentOS5
New to disable requiretty
May 19 10:40:01 xxx sudo: root : sorry, you must have a tty to run sudo ; TTY=unknown ; PWD=/www/xxx/bin ; USER=xxx ; COMMAND=/bin/sh moviepagechmod.sh
vi /etc/sudoers
#Defaults requiretty
delete rpm packages ignoring dependent error
#rpm -e –nodeps openssl-0.9.7a-33.17
list all files installed by a package
rpm -ql package_name
Setup lvm
combine /dev/sdb and /dev/sdc
if there’s partition on /dev/sdb, /dev/sdc, need to clear them first using fdisk
fdisk /dev/sdb -> d (delete partition) ->w
fdisk /dev/sdc
pvcreate /dev/sdb
pvcreate /dev/sdc
vgcreate vgrp /dev/sdb /dev/sdc
vgchange -a y vg
vgdisplay vg|grep ‘Total PE
‘lvcreate -i2 -I8 -l 70006 vg -n lv
mkfs.ext3 /dev/vg/lv
tune2fs -r 128000 /dev/vg/lv
mount /dev/vg/lv /backup
Remove lvm
#lvremove /dev/vg/lv
#vgremove vg
#fdisk /dev/sdb
#mkfs.ext3 /dev/sdb1
#tune2fs -r 128000 /dev/sdb1
(do same to /dev/sdc)
#mount /dev/sdb1 /www
Some logrotate are not working properly
added “/var/log/xxx/*/errors” into /etc/logrotate.d/xxx
and change to weekly
/usr/local/zeus/web/log/errors /var/log/xxx/*/errors {
weekly
rotate 8
missingok
create 0644 nobody nobody
compress
}
problem when search for “V&R”
V%26amp%3BR
%26 -> &
%3B -> ;
%26amp%3B -> &
Solution: change & to encoded code in query sent to html
Add:
$srch_name=eregi_replace(“&”,”%26amp%3B”,$srch_name);
before the following code
if($srch_name !=”){ $req.=”&name=$srch_name”; }
if($srch_site !=”){ $req.=”&site=$srch_site”; }
check mysql queries
mysqladmin processlist -v |less
Consider this number: 10 million. That’s how many cases of cancer are diagnosed worldwide each year. Now consider this number: 15 million. That’s how many cases of cancer the World health Organization estimates will be diagnosed in the year 2020 — a 50 percent increase — if we don’t get our act together.
Most cancers don’t develop overnight or out of nowhere. Cancer is largely predictable, the end result of a decades-long process, but just a few simple changes in your daily life can significantly reduce your risk. Here are 31 great tips. Continue reading
To check Javascript error, use Firefox Web Developer Addon
Tool -> Error Console
Got javascript error as “missing ; before statement” although there was no missing “;”
Finally found the reason is that the javascript function used number at the beginning, like
2way_func = function(){ …..}
Calculate sum of the file size
ls -l access_log.2008-12-20*|gawk ‘{a+=$5;} END {print a;}’
Edit special lines using regular expression
awk ‘/aaa/ ‘ filename
Change file names using sed
##Example: from access_log.2008-12-20.01.gz.1 to access_log.2008-12-20.01.1.gz
for file in `ls access_log.2008-12-20.*`
do
newname=`echo $file|sed ‘s/\(access_log.2008-12-20.[0-9][0-9]\).gz.\([0-9]*\)/\1.\2.gz/’`
size=`ls -l $file|awk ‘{print $5}’`
if [ $size -gt 100 ];then
echo “$file-> $newname”
fi
mv -v $file $newname
done