Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
iptables_ip(){
FILE=$1
egrep -iv "Baiduspider|bingbot|360Spider|JianKongBao|Ezooms|msnbot|Safari|AhrefsBot|Firefox|TurnitinBot|bot|AppleWebKit" $FILE|awk '{print $1}' |sort -n|uniq -c|sort -nr|awk '{if ($1>50) print $1" "$2}' >.tmp_ip
if [ -s .tmp_ip ]
then
while read line
do
@spidersea
spidersea / Linux shell脚本 while命令解决 ssh登陆单行问题
Created December 24, 2013 08:35
Linux shell脚本 while命令解决 ssh登陆单行问题
#!/bin/bash
cat list |while read line
do
echo ===============$line
TARGE_IP=`echo $line|awk '{print $3}'`
TARGE_PORT=`echo $line|awk '{print $4}'`
ssh -p $TARGE_PORT $TARGE_IP "ps axu|grep webserver" < /dev/null
RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^\/page1\/
RewriteCond %{REQUEST_URI} !^\/page2\/
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} \/page1\/ [OR]
RewriteCond %{REQUEST_URI} \/page2\/
一、下载并编译mod_rpaf模块到apache
二、启动将以下配置添加到httpd.conf
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 10.130.x.x 10.130.x.x 10.130.x.x 10.130.x.x 10.130.x.x 10.130.x.x ###前端IP
RPAFheader NS-Client-IP
三、重启apache,查看apache日志
1. 压缩参数
curl --compressed -I " http://xx.x.x.x./xxx/"
##nginx 添加jason压缩
gzip_types text/plain application/x-javascript text/css text/xml application/xml application/xml+rss text/javascript image/x-icon image/x-ms-bmp image/g application/json
##tomcat 添加jason压缩
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="application/json,application/xml,text/html,text/xml"
@spidersea
spidersea / grep_awk_sed 多核利用
Created December 24, 2013 08:37
grep/awk/sed 多核利用
如何利用多核CPU来加速你的Linux命令 — awk, sed, bzip2, grep, wc等
你是否曾经有过要计算一个非常大的数据(几百GB)的需求?或在里面搜索,或其它操作——一些无法并行的操作。数据专家们,我是在对你们说。你可能有一个4核或更多核的CPU,但我们合适的工具,例如 grep, bzip2, wc, awk, sed等等,都是单线程的,只能使用一个CPU内核。
借用卡通人物Cartman的话,“如何我能使用这些内核”?
要想让Linux命令使用所有的CPU内核,我们需要用到GNU Parallel命令,它让我们所有的CPU内核在单机内做神奇的map-reduce操作,当然,这还要借助很少用到的–pipes 参数(也叫做–spreadstdin)。这样,你的负载就会平均分配到各CPU上,真的。
BZIP2
#!/bin/bash
DATE1=`date +%Y/%m/%d`
DATE2=`date +%Y/%m/`
PIC_dir="/home/wwwroot/web/"
if [ -d ${PIC_dir} ]
then
cd ${PIC_dir} && find . -name "*.jpg" -exec convert -resize 110x150 {} {} \;
fi
#!/bin/bash
DATE=$(date +%Y%m%d)
/usr/local/webserver/mysql/bin/mysqldump -u root -ppasswd --opt dbname > $DATE
tar cfz $DATE.tar.gz $DATE
(echo "$DATE DB backup";uuencode $DATE.tar.gz $DATE.tar.gz)|mail -s "${DATE}_pangxiang_DB_backup" x.x.x@qq.com
###############################
#也可以使用如下命令进行附件发送,效果也不错
该功能用户小型个人或公司网站,由于硬件资源有限不能实用数据库进行搭建syslog系统使用。
一、系统环境变量设置
在/etc/profile中添加:
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
TTY_TERMINAL=`who -u am i|awk '{print $2}'`
DATE=`date +"%Y%m%d"`
if [ "$USER_IP" = "" ]
grant all on *.* to 'root'@'192.168.1.%' identified by '123456';
grant all on *.* to 'root'@'localhost' identified by '123456';
grant all on *.* to 'root'@'127.0.0.1' identified by '123456';