Skip to content

Instantly share code, notes, and snippets.

@deathcult
deathcult / http_monitor.sh
Last active December 31, 2015 12:19
apache httpd monitor
#!/bin/sh
logfile=/tmp/httpd.log
Date=`date '+%Y-%m-%d %H:%M:%S'`
httpd_proc_num=`pgrep httpd | wc -l`
## httpd进程数少于3,说明有异常,重启服务:
if [ $httpd_proc_num -lt 3 ]; then
echo "$Date httpd process count: $httpd_proc_num, restart it" >> $logfile
@deathcult
deathcult / iptables_drop.sh
Created December 13, 2013 18:05
iptables drop!
netstat -tan| awk '{print $5}' | cut -d: -f4| sort| uniq -c|sort -nr |awk '{if($1>10)print "iptables -I INPUT -s "$2" -j DROP"}'
@deathcult
deathcult / tcp_foreign_address.sh
Created December 13, 2013 17:04
外部tcp连接统计
netstat -tan| awk '{print $5}' | cut -d: -f1| sort| uniq -c| sort -nr
@deathcult
deathcult / frontend.md
Last active December 31, 2015 02:59
Frontend Developer Skills (or Keywords)

Frontend Developer Skills (or Keywords):

  • Yslow
  • pagespeed insights
  • YUI
  • purecss
  • bootstrap
  • html5
  • CSS3
  • CSS sprite
  • Ext JS
@deathcult
deathcult / mysql_kill_locked.sh
Created November 27, 2013 18:31
kill掉mysql Locked进程。
#!/bin/sh
## MySQL 5.1.61
## mysql_kill_locked.sh #调试
## mysql_kill_locked.sh | sh #执行
## ID != 1
mysqladmin -u* -p* processlist |grep Locked |awk '{if($2!=1)print "mysqladmin -u* -p* kill " $2}'
@deathcult
deathcult / http_redirect
Created November 27, 2013 18:27
网站升级调整。全部.php请求,都重定向到construction.html。
## .htaccess
## redirect all php request:
RewriteEngine on
RewriteCond $1 php$
RewriteRule ^(.*)$ http://www.abc.com/construction.html [L,R=301]
@deathcult
deathcult / mysql_kill_sleep_proc.sh
Last active October 11, 2016 17:53
kill mysql sleep process
#!/bin/sh
## MySQL 5.1.61
## sleep时间大于等于10秒,kill掉:
mysqladmin -u* -p* processlist |grep -i sleep |awk '{if($12>=10) print $2}' |xargs -n1 mysqladmin -u* -p* kill
@deathcult
deathcult / date_calc.sh
Created November 26, 2013 08:58
shell date calculate.
#!/bin/sh
## CentOS release 6.2
TODAY=`date '+%Y%m%d.%H'`
TOMORROW=`date -d'tomorrow' '+%Y%m%d'`
YESTERDAY=`date -d'yesterday' '+%Y%m%d'`
PREVIOUS_HOUR=`date -d'1 hour ago' '+%Y%m%d%H'`
NEXT_HOUR=`date -d'+1 hour' '+%Y%m%d%H'`
echo $NEXT_HOUR
GET ifconfig.me/all.json
curl ifconfig.me/all.json
@deathcult
deathcult / factorial
Created November 23, 2013 16:43
阶乘计算
fact = lambda x: x and x*fact(x-1) or 1
print fact(5)