技术
监测Apache运行状态,如果崩溃就重启Apache
0首先我一直没有搞清楚为什么我的Apache会经常崩溃。这可不是什么值得炫耀的事情。所以有人能帮我分析吗?我会非常感谢。
因为Apache经常崩溃,我又查不出原因,之后写一个脚本监测Apache是死是活,如果事情不对劲,就重启Apache。
分享脚本如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash Apache_Thread_Num=$(ps -e | grep -c 'httpd') Min_Normal_Thread=$(grep 'MinSpareServers' /etc/apache2/server-tuning.conf | egrep "[0-9]{1,}" -o) if [ $Apache_Thread_Num -lt $Min_Normal_Thread ]; then echo time point =`date "+%Y-%m-%d-%H-%M-%S"` echo Apache dead, alive thread less than MinSpareServers echo Apache_Thread_Num=$Apache_Thread_Num echo Min_Normal_Thread=$Min_Normal_Thread # service apache2 restart /etc/init.d/apache2 restart #else # echo time point =`date "+%Y-%m-%d-%H-%M-%S"` # echo apache alive # echo Apache_Thread_Num=$Apache_Thread_Num # echo Min_Normal_Thread=$Min_Normal_Thread fi |
然后把它加到crontab里每分钟运行,世界似乎清静一些了。
代码高亮插件的用法和语言列表
0本篇日志纯粹个人备忘,大部分读者可以直接忽略。
我使用WP-CodeBox做本站带代码可视化工具。 provides clean syntax highlighting and AJAX advanced features for embedding source code within pages or posts.Wrap code blocks with
1 |
. The LANG is supported by wide range of popular languages syntax. The FILE will create code downloading attribute. line=”n”is the starting line number, colla=”+/-” will expand/collapse the codebox.
应该也是基于GeSHi来做的。支持语言的列表见:
http://gehrcke.de/files/perm/wp-geshi-highlight/wp-geshi-highlight_languages_1_0_5.txt
download.zhuwenhao.com redirected to d.zhu.im
0偶然发现一个很简短的域名zhu.im被某人掉下来了。赶紧注册。
于是把原来的下载站download.zhuwenhao.com使用htaccess转成了d.zhu.im
大家可以使用d.zhu.im去访问我同步的Android和其他很多的源代码了。是不是方便记忆很多了?
顺便说下htaccess写法。
1 2 3 | RewriteEngine On rewritecond %{http_host} !^d\.zhu\.im [NC] rewriterule ^(.*)$ http://d.zhu.im/$1 [R=301,NC] |
grep搜索同时包含多个关键字的文件
0grep -nirl ‘xxx’ ./ | xargs grep -Hnir “yyy”
命令的前半截先列举出包含’xxx’关键字的文件路径和文件名。后半句在这些文件中搜索’yyy’关键字并列出。
tar解压当前目录里所有的压缩文件
0使用命令
find ./ *.tar.bz2 -exec tar xjvf {} \;
解压当前目录下所有的tar.bz2格式压缩文件。
参考来源:http://www.seanodonnell.com/code/?id=46