<?xml version="1.0"?>




<rss version="2.0">
   <channel>
      <title>开到荼靡</title>
      <link>http://billtt.com/blog.php</link>
      <description>BillTT's blog</description>
      <language>zh-cn</language>
      <pubDate>2010-08-25 22:29:54.0</pubDate>

      <lastBuildDate>2010-08-25 22:29:54.0</lastBuildDate>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs>
      <generator>billtt.com</generator>
      <managingEditor>i@billtt.com</managingEditor>
      <webMaster>i@billtt.com</webMaster>
	  
      <item>

         <title>MySQL时间处理函数整理</title>
         <link>http://billtt.com/blog.php?blogId=138</link>
         <description><![CDATA[最近时不时地需要写一些数据查询的sql脚本，其中经常用到各种时间处理函数，每次都打开MySQL手册查阅，甚是麻烦。现将其整理一下。<br/>在数据库里存放时间的方法一般可分为字符串、timestamp、datetime和bigint（unix timestamp 经典的“1970-01-01 0:00 UTC”。而我们用到的时间处理函数无非就是在这些类型中转换，或者提取某一个字段（比如月、日等）。<br/>其实timestamp和datetime可以看成是有特定格式的字符串，两者的使用方法基本一样（时间范围不同）。下面就都用timestamp来举例。<br/>如果要从一个非标准格式的字符串转换成timestamp的话，可以使用str_to_date，比如str_to_date(str, "%d/%m/%Y %H:%i:%s")；反过来，若将timestamp格式化成其他格式，可使用date_format(date, "%d/%m/%Y %H:%i:%s")。<br/>如果要从timestamp转换成距离UTC 1970年1月1日0点0分的秒数的话，可使用unix_timestamp(date)，省略参数表示当前时间；反过来操作的话使用from_unixtime(seconds)。<br/>要注意的是，Java中的System.currentTimeMillis得到的时间含义与此（unix timestamp）相同，但是单位是毫秒。<br/>若要提取时间的某一个字段，则可以使用date_format，在格式中仅写某个值。<br/>下面看一些例子。<br/>假设我们需要将字符串"5/25/2010 13.34.33"转换成Java中System.currentTimeMillis等效的值。首先，该字符串不是timestamp标准格式，所以需要先使用str_to_date转换一下。然后可使用unix_timestamp转换成秒数，最后变成毫秒数。也就是：unix_timestamp(str_to_date("5/25/2010 13.34.33", "%d/%m/%Y %H.%i.%s")) * 1000<br/>再比如说，数据库里面payment表的time字段记录的是时间毫秒数，而现在需要按月统计支付金额(amount)，那么可以这么做：<br/>select date_format(from_unixtime(time/1000),"%Y/%m") as mon, sum(amount) from payment group by mon<br/>当然，这只是一种粗略的方法，实际上可能还需要考虑时区的影响。<br/>MySQL中时间相关函数还有很多，这里只是举了一些常用的例子。详细的函数列表和用法可参考官方手册：<br/><a href='http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html' target='_blank'>http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html</a>]]></description>
         <pubDate>2010-08-25 22:29:54.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=138</guid>

      </item>
	  
      <item>

         <title>删除Win7下的休眠文件</title>
         <link>http://billtt.com/blog.php?blogId=137</link>
         <description><![CDATA[现在内存越来越大，休眠文件太占磁盘了，而平时一般都不用休眠的。<br/>要删除hiberfil.sys很简单，管理员命令行下输入：<br/>powercfg -h off<br/>就可以了，再看看C盘，是不是大了好多G呢]]></description>
         <pubDate>2009-11-24 12:01:20.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=137</guid>

      </item>
	  
      <item>

         <title>禁用Linux控制台的自动黑屏</title>
         <link>http://billtt.com/blog.php?blogId=136</link>
         <description><![CDATA[一般来说，可以通过如下命令来禁用（必须从控制台输入）：<br/>setterm -powersave off -powerdown 0 -blank 0<br/><br/>如果想从ssh session来设置的话，可执行如下命令：<br/>sudo sh -c 'setterm -blank 0 -powersave off -powerdown 0 &lt; /dev/console &gt; /dev/console 2&gt;&1'<br/><br/>这一点对于服务器来说比较有用，因为服务器的控制台一般不会去操作的，都是通过远程登录。这样万一出现个kernel panic，屏幕是黑的，啥信息都得不到了。]]></description>
         <pubDate>2009-10-22 01:22:50.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=136</guid>

      </item>
	  
      <item>

         <title>使用iptables实现透明代理</title>
         <link>http://billtt.com/blog.php?blogId=135</link>
         <description><![CDATA[最近有这么个需求，即从某台机器（A）无法访问到服务器B的p0端口，因此需要从另一台机器C的p1端口中转一下。<br/>当然网上有很多代理的方法，包括代理软件、ssh隧道等，但是应用程序不支持代理，因此必须使用透明代理，即在A的应用中将C设置为服务器，C将所有到达其p1端口的包转发给B的p0端口，然后B的所有回复都由C转发回A。当然，C必须做地址转换，使得A认为自己在与C通信，B也认为自己在与C通信。<br/>这么看来这个需求其实和NAT很类似，唯一不同的是这里的A、B和C的地址都是global地址。<br/>研究了一下，其实可以使用类似NAT的方法来做，即在C上配置2个SNAT和1个DNAT，A和B都不用配置。<br/>其中A发往C的包使用DNAT转换，C发往A和B的包使用SNAT转换。具体配置如下：<br/><br/>-A PREROUTING -s ! b.ip -d c.ip -p tcp -m tcp --dport p1 -j DNAT --to b.ip:p0<br/><br/>-A POSTROUTING -s ! b.ip -d b.ip -p tcp -m tcp --dport p0 -j SNAT --to c.ip<br/><br/>-A POSTROUTING -s b.ip -d !b.ip -p tcp -m tcp --sport p0 -j SNAT --to c.ip<br/><br/>可以发现，如果将C看成是NAT Box，B看成是内网机器，A看成是外网机器的话，以上配置与加了端口转发的NAT的唯一区别就是多了第二条规则。这是因为B的IP是Global的，它访问A的时候路由不经过C，所以A到B仅作DNAT是不够的，还必须用SNAT把源地址换成C的地址。<br/><br/>btw，别忘了启用ip_forward]]></description>
         <pubDate>2009-09-26 21:56:47.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=135</guid>

      </item>
	  
      <item>

         <title>海底总动员上线啦</title>
         <link>http://billtt.com/blog.php?blogId=134</link>
         <description><![CDATA[欢迎来玩哦 ：）<a href="http://apps.xiaonei.com/oceansecret" target="_blank">点此进入：）</a><br/>]]></description>
         <pubDate>2009-08-10 13:50:24.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=134</guid>

      </item>
	  
      <item>

         <title>Ubuntu源 (9.04)</title>
         <link>http://billtt.com/blog.php?blogId=133</link>
         <description><![CDATA[备忘<br/>#Tsinghua<br/>deb ftp://ftp3.tsinghua.edu.cn/mirror/ubuntu/ubuntu/ jaunty main multiverse restricted universe<br/>deb ftp://ftp3.tsinghua.edu.cn/mirror/ubuntu/ubuntu/ jaunty-backports main multiverse restricted universe<br/>deb ftp://ftp3.tsinghua.edu.cn/mirror/ubuntu/ubuntu/ jaunty-proposed main multiverse restricted universe<br/>deb ftp://ftp3.tsinghua.edu.cn/mirror/ubuntu/ubuntu/ jaunty-security main multiverse restricted universe<br/>deb ftp://ftp3.tsinghua.edu.cn/mirror/ubuntu/ubuntu/ jaunty-updates main multiverse restricted universe<br/><br/><br/># taiwan<br/>deb http://debian.nctu.edu.tw/ubuntu jaunty main multiverse restricted universe<br/>deb http://debian.nctu.edu.tw/ubuntu jaunty-backports main multiverse restricted universe<br/>deb http://debian.nctu.edu.tw/ubuntu jaunty-proposed main multiverse restricted universe<br/>deb http://debian.nctu.edu.tw/ubuntu jaunty-security main multiverse restricted universe<br/>deb http://debian.nctu.edu.tw/ubuntu jaunty-updates main multiverse restricted universe<br/>deb-src http://debian.nctu.edu.tw/ubuntu jaunty main multiverse restricted universe<br/>deb-src http://debian.nctu.edu.tw/ubuntu jaunty-backports main multiverse restricted universe<br/>deb-src http://debian.nctu.edu.tw/ubuntu jaunty-proposed main multiverse restricted universe<br/>deb-src http://debian.nctu.edu.tw/ubuntu jaunty-security main multiverse restricted universe]]></description>
         <pubDate>2009-07-11 21:37:11.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=133</guid>

      </item>
	  
      <item>

         <title>终于搞定win7下的支付宝宝</title>
         <link>http://billtt.com/blog.php?blogId=132</link>
         <description><![CDATA[其实很早就看到这个文章了，不过里面有提到雅虎助手，所以当时就忽略了……<br/>现在也想通了：反正IE只是用来操作网银之类的，助手就助手吧<br/>原文提到了两类问题，分别是密码无法输入和证书导入的问题，我前一个倒没有遇到过，一直都是证书问题，所以就在此转载一下证书问题的解决（省略原文的详细描述，直接写步骤）：<br/><br/>1、安装上“雅虎助手”，然后在插件管理里面把对 Microsoft Certificate Enrollment CAB的 屏蔽解除。当然过后就可以把雅虎助手删除掉。<br/><br/>2、 下载xenroll.dll文件, 放到Windows/system32 目录下，然后运行regsvr32 xenroll.dll<br/><a href="http://blog.alipay.com/wp-content/2009/02/xenroll.dll">点此下载该文件</a>]]></description>
         <pubDate>2009-06-03 11:02:21.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=132</guid>

      </item>
	  
      <item>

         <title>好久没有写科幻的东东了</title>
         <link>http://billtt.com/blog.php?blogId=131</link>
         <description><![CDATA[不玩世界上最强大的网游若干周之后，又开始看科幻世界了，短时间内把堆积了好久的几期杂志看完了，有以下一些感觉：<br/>1、现在新人的文章还是有好多看都看不懂的，感觉都是华丽的语句堆砌起来的，没有有意思的故事情节或者令人惊奇的创意（难道是所谓的“后现代”？）。<br/>2、发现一篇银河奖征文很不错：《擦肩而过》，作者七月，以前都没怎么关注过这个人。文章整体感觉很有大刘的气势，尤其在结尾的地方。文章类型是科幻+灾难，这两者向来都是我最感兴趣的题材。网上找了一下，竟然在百度贴吧有全文（<a href="http://tieba.baidu.com/f?z=560185829&ct=335544320&lm=0&sc=0&rn=30&tn=baiduPostBrowser&word=%BF%C6%BB%C3%CA%C0%BD%E7&pn=0&rs1=1" target="_blank">此</a>）。后来又看到了这个的续篇，感觉风格有些变化，虽然结局很不错，但是中间的文笔貌似有点“后现代”。<br/>3、何夕的文章一直感觉挺不错的，尤其是《伤心者》，很有感觉。不过从最新的那篇《亿万年后的来客》来看，他的风格已经发生了变化，像不少人所说的那样，变得有点“倪匡”了。<br/>4、又看了一遍《球状闪电》，感觉依然很震撼。大刘的文章好像Disney的动画一样，每一次看都会发现更多精致的细节。]]></description>
         <pubDate>2009-05-27 15:04:04.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=131</guid>

      </item>
	  
      <item>

         <title>VirtualBox 2.2无法卸载解决方案</title>
         <link>http://billtt.com/blog.php?blogId=130</link>
         <description><![CDATA[google到的，做个记录。（ps 卸载2.2是为了装2.2.2，该版本解决了2.2中client os无法获取IP地址问题）<br/>出处：<br/>http://www.virtualbox.org/ticket/3701<br/><br/>原帖：<br/>For those unable to uninstall VBox 2.2:<br/>To be able to uninstall you would need to copy the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion?\DIFxApp\Components registry key (and its sub-keys) from the HKEY_CURRENT_USER to the HKEY_LOCAL_MACHINE branch.<br/><br/>Here are the steps for doing this:<br/><br/> &nbsp; &nbsp; 1. run the registry editor (press windows + R , type regedit and press OK)<br/> &nbsp; &nbsp; 2. in the left pane browse to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion?\DIFxApp\Components -&gt; there should be some sub-keys having GUID names located under the "Components"<br/> &nbsp; &nbsp; 3. export the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion?\DIFxApp\Components to some file (right-click the "Components" key, select "Export", type a file name where you want to export the settings (e.g. C:\foo.reg) )<br/> &nbsp; &nbsp; 4. open the exported .reg file (either with notepad or some other text editor or right-click it in explorer and select "Edit")<br/> &nbsp; &nbsp; 5. substitute the HKEY_CURRENT_USER with HKEY_LOCAL_MACHINE in the file, save and close the ditor.<br/> &nbsp; &nbsp; 6. import the .reg file (either double-click it in the explorer or in the registry editor use menu File-&gt;Import-&gt; browse to a file, select it and press "Open") <br/><br/>Once this is done you should be able to uninstall.]]></description>
         <pubDate>2009-05-13 16:02:28.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=130</guid>

      </item>
	  
      <item>

         <title>【转载】身体小窍门</title>
         <link>http://billtt.com/blog.php?blogId=129</link>
         <description><![CDATA[转自煎蛋（http://jandan.net/2007/07/09/body-tricks-everyone-should-know.html），有点意思。<br/>原始链接：http://www.mohammadi.ca/?itemid=274<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 1、如果你的喉咙痒，挠你的耳朵！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;当耳朵里的神经被刺激，会造成咽喉的反射作用，引起肌肉痉挛，这种痉挛会缓解发痒。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 2、体验超声波听觉！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;右耳比左耳更善于听快节奏的谈话，而左耳更善于听取音乐的曲调。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 3、克服你原始的冲动！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;想嘘嘘？附近没有洗手间？那么请想象一下杰西卡·辛普森。满脑子性幻想会让你好过点。为了达到最佳效果，试试辛普森的“These Boots Are Made for Walking”那盘碟。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 4、感觉不到疼痛！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;德国研究者发现在打针时咳嗽能减轻针头带来的痛苦。这个小窍门会引起突然的暂时性的胸内和脊柱内压力上升，从而抑制脊柱的疼痛传导组织。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 5、让你的鼻子通畅！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;一个简单、快速、又便宜的缓解鼻窦压力的方式是不时用舌头推挤口腔的上部，接着用一根手指按压你的眉间。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 6、对症下葯！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;担心晚上鸡翅又从胃里飞出来？朝左侧卧睡觉吧！研究表明左侧卧睡的人受胃酸返流之苦的可能性较小。因为食道和胃以一定的角度连接，当你向右侧卧时，胃比食道要高，会让胃酸流向喉管。而左侧卧时，胃比食道要低，所以重力对你有利。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 7、不张嘴就能治好你的牙疼！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;你只需在虎口（the V-shaped webbed area between your thumb and index finger）上揉化一块冰即可。与不用冰相比，这种方法能减少 50% 的疼痛感。虎口处的神经会刺激大脑的某个区域，从而阻止面部和手部传来的疼痛信号。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 8、让烧伤消失！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;当你不小心烧伤手指，立即清洁皮肤并用未受伤的手掌轻轻按压伤处，然后冰敷－－冰块会迅速减轻你的疼痛。这种自然的方法能使你烧伤的皮肤恢复到正常的温度，使皮肤不容易起水疱。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 9、让世界停止旋转！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;喝多了觉得眩晕？请把手扶在稳固的物体上。稳定物体传来的触觉给了大脑二次判断，让你更有平衡感。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 10、胁部不再疼痛！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果你和大多数人一样，那么你跑步时在右脚触地的同时呼气。这会给你的肝脏向下的压力，从而向下拉扯横隔膜造成一侧刺痛。解决办法：在左脚触地时呼气。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 11、用一只手指止血！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;捏紧鼻子并仰头是一个止住鼻血的不错方法－－如果你不介意被自己的阳性O型血哽住。一种更文明的方法是：在你的上牙龈处塞些棉花－－就在你的人中（small dent below your nose）后面，然后用力按压它。大多数流血来自隔膜的前部（将鼻子分开的软骨墙），所以按压人中能帮助止血。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 12、让你的心脏保持平静！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;在试图平息第一次约会的紧张不安？对你的大拇指吹气吧，这会使你的心率恢复正常。迷走神经能通过呼吸来控制心率。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 13、解冻你的大脑！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;冰激凌（Chipwich？？）吃得太多太快会让一些人的感觉大脑发冷。原因是上颚的神经变得很冷，使你的身体认为你的大脑也被冻结，引起“冰激凌头痛”。为了抵消这种效果，可以用平着舌头去紧贴上颚，覆盖面越大约好，越用力头痛感越快消退。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 14、防止近视！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;近视很少是因为遗传因素引起，通常是由“近点紧张”引起。换句话说，你盯着电脑屏幕看得太久。预防的方法是：每天每隔几小时就闭上眼睛，绷紧全身肌肉，然后深深吸口气，几秒后再呼出同时放松肌肉。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 15、叫醒“死去的”身体！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果你在开车或以奇怪的姿势久坐时双手麻木了，请左右摇晃你的头。这能在一分钟内毫无痛苦地驱散你的麻木感（pins and needles）<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 16、让朋友们对你印象深刻！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;下次你参加Party时，试试这个小把戏：让一个人侧伸出一只手臂，手掌朝下，并要求他保持这个姿势。然后你用两根手指按压他的手腕，他仍能保持原来的姿势。现在，让他把脚放到一个半英寸高的平面上（比如一摞杂志），再去按压他的手腕。这次，他甚至没法站直。原因是他的脊椎已经因为臀部的偏移而偏移。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 17、水下呼吸！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果你死命地想取回池塘水底的那枚25分硬币，先短促有力地吸几口气。当你在水下时，不是因为缺氧使你拼命地想呼吸，而是因为二氧化碳的增加使你的血液呈酸性，从而给你的大脑传到不好的信号。而当你强力呼吸时，氧的注入降低了血液里的酸。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;* 18、了解大脑！<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果你明天要作一个演讲，最好在睡前再看一遍。因为大多数记忆强化过程发生在睡眠中，在睡前读的任何东西都更可能被编码成长期记忆。<br/><br/>]]></description>
         <pubDate>2009-03-25 19:32:09.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=129</guid>

      </item>
	  
      <item>

         <title>Word使用一例（无法显示图片问题）</title>
         <link>http://billtt.com/blog.php?blogId=128</link>
         <description><![CDATA[今天打开几个文档，发现里面的图片都显示不出来，只有黑色的框框。记得以前也遇到过这样的问题，但是忘记怎么解决的了。<br/>凭借着强大的SE，找到了解决方案：在Word选项的“高级”中，找到“显示图片框”，把勾去掉即可。看来是Word同学可耐的图片框把图片都挡住了-_-]]></description>
         <pubDate>2009-03-08 16:50:02.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=128</guid>

      </item>
	  
      <item>

         <title>Ubuntu, sudo 与 PATH</title>
         <link>http://billtt.com/blog.php?blogId=127</link>
         <description><![CDATA[好吧，我承认，这个标题的目的是SEO。<br/>问题是这样的，最近偶然发现在ubuntu下使用sudo的话会丢失当前的PATH环境变量。比如说，我有一个目录专门放脚本: /scripts/，当前用户的PATH也加入了该路径。其中有一些脚本是要super权限的，比如/scripts/abc。于是使用sudo abc，发现ubuntu说找不到abc这个命令。<br/>然后我想到可能sudo使用的是ROOT的环境变量，于是将这个该死的目录加入到/root/下的相关文件PATH里，然后还是不行。<br/>上网查了下，有人说改/etc/environment中的PATH，可是还不行。<br/>最后发现，原来sudo这个程序在编写的时候加入了这样一个功能：重置PATH为某个安全的组合（类似于/bin:/usr/bin之类的），这样不管你怎么折腾，使用sudo的时候PATH总是会丢的。<br/>所以有两个解决方案，要么把所有的脚本拷到默认路径中（或符号链接），要么就在sudo的时候打全路径。]]></description>
         <pubDate>2009-03-06 16:29:08.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=127</guid>

      </item>
	  
      <item>

         <title>递归touch —— find使用一例</title>
         <link>http://billtt.com/blog.php?blogId=126</link>
         <description><![CDATA[最近某次编译一个东东的时候，由于系统时间的问题，报了一堆warning。于是想要把所有源代码的修改时间都重置一下。首先想到的是touch，可是用了下发现touch不能递归的修改子文件夹里的东西。上网查了一下，可以用find的execute参数来搞定：<br/>find ./ -execute touch {} \;<br/>该命令意思是将当前文件夹及其所有子文件夹的东西全挖出来，挨个用touch命令搞一下。{}表示将具体的每一个文件名作为参数传给touch。其实就是一个针对所有文件的循环了。<br/>Linux的命令真是无穷尽呀。]]></description>
         <pubDate>2009-03-06 16:21:17.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=126</guid>

      </item>
	  
      <item>

         <title>同时运行多个Tomcat实例（Linux）</title>
         <link>http://billtt.com/blog.php?blogId=125</link>
         <description><![CDATA[此为“同时运行多个MySQL实例”的姊妹篇 ^_^<br/>由于Tomcat是跨平台的，所以以下的方法对Windows也可用。<br/>基本思想还是一份程序+多份配置。具体来说，Tomcat启动的时候使用两个环境变量——CATALINA_HOME和CATALINA_BASE分别表示程序和配置的位置。程序指的是bin、lib目录，配置指的是conf、temp、work、logs和webapps的目录。<br/>这样一来就很好办了，假设在~/tomcat下新建一份实例，首先将tomcat安装目录中的conf复制过来，然后新建work temp logs webapps目录，将要部署的应用放到webapps里面，修改conf下的server.xml，将其中的端口号都改掉（Server、Connector），然后使用如下的脚本来启动Tomcat（假设tomcat程序位于/usr/share/tomcat）：<br/><br/>#!/bin/bash<br/><br/>CATALINA_HOME=/usr/share/tomcat<br/>CATALINA_BASE=/home/xxx/tomcat<br/>CATALINA_PID=/home/xxx/tomcat/pid<br/><br/>export CATALINA_HOME CATALINA_BASE CATALINA_PID<br/><br/>/usr/share/tomcat/bin/catalina.sh start<br/><br/>用以下脚本停止Tomcat：<br/>#!/bin/bash<br/><br/>CATALINA_HOME=/usr/share/tomcat<br/>CATALINA_BASE=/home/xxx/tomcat<br/>CATALINA_PID=/home/xxx/tomcat/pid<br/><br/>export CATALINA_HOME CATALINA_BASE CATALINA_PID<br/><br/>/usr/share/tomcat/bin/catalina.sh stop -force<br/><br/>当然，除了CATALINA_HOME等变量，还可以指定其他的参数，比如<br/>JAVA_OPTS="-Xms800m -Xmx1500m "<br/>用于设置内存限制等。<br/>]]></description>
         <pubDate>2009-01-07 14:28:45.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=125</guid>

      </item>
	  
      <item>

         <title>同时运行多个MySQL实例(Linux)</title>
         <link>http://billtt.com/blog.php?blogId=124</link>
         <description><![CDATA[最近研究了下如何在一台机器上运行多份MySQL实例。这种做法最直观的应用就是一台服务器部署多个web应用，为保证互不干扰，需要创建多个MySQL实例（并非简单的多个database）。<br/>其实做法很简单，基本思想是使用同一份程序+多份配置和数据文件即可。假设现在要新建一个MySQL实例（~/newdb），复制配置文件（my.cnf）到~/newdb/my.cnf，复制数据文件夹 /var/lib/mysql 到 ~/newdb/data，然后修改my.cnf文件，主要关注以下部分：<br/>[client]<br/>port &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 3307<br/>socket &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= /home/xxx/newdb/mysql.sock<br/><br/>[mysqld_safe]<br/>socket &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= /home/xxx/newdb/mysql.sock<br/><br/>[mysqld]<br/>pid-file &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= /home/xxx/newdb/mysql.pid<br/>socket &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= /home/xxx/newdb/mysql.sock<br/>port &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 3307<br/>datadir &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = /home/xxx/newdb/data<br/><br/>即所有的sock、pid、log以及数据文件的路径都得修改，另外端口号也要修改。<br/><br/>然后修改文件夹权限：<br/>chown -R mysql:mysql ~/newdb<br/><br/>最后，使用如下命令启动新数据库：<br/>sudo /usr/bin/mysqld_safe --defaults-file=~/newdb/my.cnf &<br/><br/>使用如下命令停止数据库：<br/>sudo kill `cat ~/newdb/mysql.pid`<br/><br/>注：如果系统运行了apparmor（比如ubuntu），需要修改相应的配置。详情见my.cnf文件的相关注释。]]></description>
         <pubDate>2009-01-07 14:15:32.0</pubDate>
         <guid>http://billtt.com/blog.php?blogId=124</guid>

      </item>
	  
   </channel>
</rss>