<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wayne</title>
	<atom:link href="http://zhengwei.name/feed/" rel="self" type="application/rss+xml" />
	<link>http://zhengwei.name</link>
	<description>在思考中成长, :)</description>
	<lastBuildDate>Sat, 28 Apr 2012 03:57:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>将 cron 的日志独立记录到 /var/log/cron（Ubuntu）</title>
		<link>http://zhengwei.name/2012/04/%e5%b0%86cron%e7%9a%84%e6%97%a5%e5%bf%97%e7%8b%ac%e7%ab%8b%e8%ae%b0%e5%bd%95%e5%88%b0varlogcron%ef%bc%88ubuntu%ef%bc%89/</link>
		<comments>http://zhengwei.name/2012/04/%e5%b0%86cron%e7%9a%84%e6%97%a5%e5%bf%97%e7%8b%ac%e7%ab%8b%e8%ae%b0%e5%bd%95%e5%88%b0varlogcron%ef%bc%88ubuntu%ef%bc%89/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 11:35:36 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=276</guid>
		<description><![CDATA[修改rsyslog文件，将/etc/rsyslog.d/50-default.conf 文件中的#cron.*前的#删掉 重启rsyslog服务service rsyslog restart 重启cron服务service cron restart more /var/log/cron.log #查看结果 来源：请问ubuntu中 cron 服务的默认日志存放位置]]></description>
			<content:encoded><![CDATA[<ol>
<li>修改rsyslog文件，将/etc/rsyslog.d/50-default.conf 文件中的#cron.*前的#删掉</li>
<li>重启rsyslog服务service rsyslog restart</li>
<li>重启cron服务service cron restart</li>
<li>more /var/log/cron.log #查看结果</li>
</ol>
<p>来源：<a title="请问ubuntu中 cron 服务的默认日志存放位置" href="http://forum.ubuntu.org.cn/viewtopic.php?f=54&amp;t=218863" target="_blank">请问ubuntu中 cron 服务的默认日志存放位置</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2012/04/%e5%b0%86cron%e7%9a%84%e6%97%a5%e5%bf%97%e7%8b%ac%e7%ab%8b%e8%ae%b0%e5%bd%95%e5%88%b0varlogcron%ef%bc%88ubuntu%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby 工作笔记</title>
		<link>http://zhengwei.name/2012/03/ruby-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/</link>
		<comments>http://zhengwei.name/2012/03/ruby-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 02:46:26 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=271</guid>
		<description><![CDATA[在1.9中，Iconv#iconv已经不推荐使用，请用String#encode(!)替代 标准库一般都为小写，require ”, pkg must be lowcase 读取utf-8页面报无效字符错误时，执行String#.force_encoding &#8216;utf-8&#8242;即可，其他编码参考处理 格式化时间Time.now.strftime(&#8216;%Y-%m-%d %H:%i&#8217;) 要以module::method的方式调用方法时，方法名前面要加self.，表示是实例方法 ruby的主文件为 $0 改变工作目录 Dir.chdir File.dirname(__FILE__)]]></description>
			<content:encoded><![CDATA[<ul>
<li>在1.9中，Iconv#iconv已经不推荐使用，请用String#encode(!)替代</li>
<li>标准库一般都为小写，require ”, pkg must be lowcase</li>
<li>读取utf-8页面报无效字符错误时，执行String#.force_encoding &#8216;utf-8&#8242;即可，其他编码参考处理</li>
<li>格式化时间Time.now.strftime(&#8216;%Y-%m-%d %H:%i&#8217;)</li>
<li>要以module::method的方式调用方法时，方法名前面要加self.，表示是实例方法</li>
<li>ruby的主文件为 $0</li>
<li>改变工作目录 Dir.chdir File.dirname(__FILE__)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2012/03/ruby-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 工作笔记</title>
		<link>http://zhengwei.name/2012/03/apache-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/</link>
		<comments>http://zhengwei.name/2012/03/apache-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 14:24:20 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=265</guid>
		<description><![CDATA[域名重定向 RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]]]></description>
			<content:encoded><![CDATA[<p>域名重定向</p>
<p><code>RewriteCond %{HTTP_HOST} ^example.com [NC]<br />
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]</code></p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2012/03/apache-%e5%b7%a5%e4%bd%9c%e7%ac%94%e8%ae%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac 下使用 rvm 安装 ree 报段错误</title>
		<link>http://zhengwei.name/2012/01/mac-%e4%b8%8b%e4%bd%bf%e7%94%a8-rvm-%e5%ae%89%e8%a3%85-ree-%e6%8a%a5%e6%ae%b5u%e9%94%99%e8%af%af/</link>
		<comments>http://zhengwei.name/2012/01/mac-%e4%b8%8b%e4%bd%bf%e7%94%a8-rvm-%e5%ae%89%e8%a3%85-ree-%e6%8a%a5%e6%ae%b5u%e9%94%99%e8%af%af/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 16:44:14 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=262</guid>
		<description><![CDATA[背景 系统版本：Mac OS X Lion 使用 rvm install ree 报错：./ext/purelib.rb:2: [BUG] Segmentation fault 解决方法 export CC=/usr/bin/gcc-4.2 如果还是无法安装，请尝试先 rvm remove ree 后再行安装，即： rvm remove ree export CC=/usr/bin/gcc-4.2 rvm install ree 参考 《Segmentation fault in (RVM) REE installation》 《Segmentation fault while installing &#8230; <a href="http://zhengwei.name/2012/01/mac-%e4%b8%8b%e4%bd%bf%e7%94%a8-rvm-%e5%ae%89%e8%a3%85-ree-%e6%8a%a5%e6%ae%b5u%e9%94%99%e8%af%af/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>背景</strong></p>
<p>系统版本：Mac OS X Lion<br />
使用 rvm install ree 报错：./ext/purelib.rb:2: [BUG] Segmentation fault</p>
<p><strong>解决方法</strong></p>
<blockquote><p>export CC=/usr/bin/gcc-4.2</p></blockquote>
<p>如果还是无法安装，请尝试先 rvm remove ree 后再行安装，即：</p>
<blockquote><p>rvm remove ree<br />
export CC=/usr/bin/gcc-4.2<br />
rvm install ree</p></blockquote>
<p><strong>参考</strong></p>
<ul>
<li><a href="https://gist.github.com/1098549" target="_blank">《Segmentation fault in (RVM) REE installation》</a></li>
<li><a href="http://groups.google.com/group/emm-ruby/browse_thread/thread/b58b617d9bc7a222" target="_blank">《Segmentation fault while installing REE on OS X 10.6.7》</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2012/01/mac-%e4%b8%8b%e4%bd%bf%e7%94%a8-rvm-%e5%ae%89%e8%a3%85-ree-%e6%8a%a5%e6%ae%b5u%e9%94%99%e8%af%af/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>多版本环境下，将PHP扩展编译安装至指定版本目录下</title>
		<link>http://zhengwei.name/2011/12/%e5%a4%9a%e7%89%88%e6%9c%ac%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8c%e5%b0%86php%e6%89%a9%e5%b1%95%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e8%87%b3%e6%8c%87%e5%ae%9a%e7%89%88%e6%9c%ac%e7%9b%ae%e5%bd%95/</link>
		<comments>http://zhengwei.name/2011/12/%e5%a4%9a%e7%89%88%e6%9c%ac%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8c%e5%b0%86php%e6%89%a9%e5%b1%95%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e8%87%b3%e6%8c%87%e5%ae%9a%e7%89%88%e6%9c%ac%e7%9b%ae%e5%bd%95/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 17:15:52 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Mac OS]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=259</guid>
		<description><![CDATA[今晚在 MBP 上装 mongo 开发环境时遇到了个问题，在此记录下。 环境 MacOS Lion 自带PHP 5.3.6，安装在 /usr 下，另外自己又编译安装了PHP 5.3.8，安装在 /opt/php 下，也就是说目前系统存在两个版本的 PHP，根据 $PATH 的查询顺序，默认的 PHP 版本为系统自带的 5.3.6 问题 &#38; 解决方法 在编译安装 mongo 扩展时发现在 make install 时，扩展会被安装至 /usr/lib/php/extensions/no-debug-non-zts-20090626/，这并非我要的结果，原先想直接 copy 到 5.3.8 版本目录下，后来想想编译环境可能会不同，怕会有版本差异导致运行不稳定，还是研究下吧。 重新解压缩源码，使用 5.3.8 版本的 phpize 配置完后发现目录下的 &#8230; <a href="http://zhengwei.name/2011/12/%e5%a4%9a%e7%89%88%e6%9c%ac%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8c%e5%b0%86php%e6%89%a9%e5%b1%95%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e8%87%b3%e6%8c%87%e5%ae%9a%e7%89%88%e6%9c%ac%e7%9b%ae%e5%bd%95/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今晚在 MBP 上装 mongo 开发环境时遇到了个问题，在此记录下。</p>
<p><strong>环境</strong></p>
<p>MacOS Lion 自带PHP 5.3.6，安装在 /usr 下，另外自己又编译安装了PHP 5.3.8，安装在 /opt/php 下，也就是说目前系统存在两个版本的 PHP，根据 $PATH 的查询顺序，默认的 PHP 版本为系统自带的 5.3.6</p>
<p><strong>问题 &amp; 解决方法</strong></p>
<p>在编译安装 mongo 扩展时发现在 make install 时，扩展会被安装至 /usr/lib/php/extensions/no-debug-non-zts-20090626/，这并非我要的结果，原先想直接 copy 到 5.3.8 版本目录下，后来想想编译环境可能会不同，怕会有版本差异导致运行不稳定，还是研究下吧。</p>
<p>重新解压缩源码，使用 5.3.8 版本的 phpize 配置完后发现目录下的 configure.in 文件被更新了，打开粗阅了下发现和 php-config 有关，经过尝试后得出解决方法：</p>
<blockquote><p>cd mongo-1.2.6<br />
/opt/php/bin/phpize<br />
./configure &#8211;prefix=/opt/php &#8211;with-php-config=/opt/php/bin/php-config<br />
make<br />
make install</p></blockquote>
<p>关键在于第三行指定 php-config 语句。最终 make install 执行后显示：</p>
<blockquote><p>Installing shared extensions:     /opt/php/lib/php/extensions/no-debug-non-zts-20090626/</p></blockquote>
<p>至此问题解决。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/12/%e5%a4%9a%e7%89%88%e6%9c%ac%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8c%e5%b0%86php%e6%89%a9%e5%b1%95%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e8%87%b3%e6%8c%87%e5%ae%9a%e7%89%88%e6%9c%ac%e7%9b%ae%e5%bd%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacOS 中的扩展属性</title>
		<link>http://zhengwei.name/2011/12/macos-%e4%b8%ad%e7%9a%84%e6%89%a9%e5%b1%95%e5%b1%9e%e6%80%a7/</link>
		<comments>http://zhengwei.name/2011/12/macos-%e4%b8%ad%e7%9a%84%e6%89%a9%e5%b1%95%e5%b1%9e%e6%80%a7/#comments</comments>
		<pubDate>Sun, 25 Dec 2011 03:03:38 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Mac OS]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=258</guid>
		<description><![CDATA[在终端中输入 ls -l 常常可以看到部分文件的结尾含有@符号，如： -rw-r&#8211;r&#8211;@  1 Wayne  staff   14789551 10 13 20:59 php-5.3.8.tar.gz 平时在忙工作就没细究，直到今天在v2ex看到有朋友提出了这个问题，参考了回帖中提及的资料做了此份笔记。 它是什么 文件的扩展属性标记 存放文件的元数据信息，存储在HFS文件系统内 常规浏览时不可见 许多流行的文件系统都支持这类元数据 除了@，还有+，表明文件拥有非标准的权限集，这些权限集在一些ACLs系统中使用 查看元数据属性的方式 ls -@ 即可。 注：com.apple.quarantine 属性表面文件是从互联网下载到本地的，在首次打开文件时候会弹出提示框要求用户是否确认要打开此文件，如果选“是”，此属性即被清除 如何管理 xattr用于访问和管理这些元数据，用法如下： xattr &#60;file&#62; 打印元数据 xattr -l &#60;file&#62; 打印详细的元数据信息，如：文件下载工具、下载时间 xattr -w &#60;attr&#62; &#60;file&#62; &#8230; <a href="http://zhengwei.name/2011/12/macos-%e4%b8%ad%e7%9a%84%e6%89%a9%e5%b1%95%e5%b1%9e%e6%80%a7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>在终端中输入 ls -l 常常可以看到部分文件的结尾含有@符号，如：</p>
<blockquote><p>-rw-r&#8211;r&#8211;<span style="color: #ff0000;">@</span>  1 Wayne  staff   14789551 10 13 20:59 php-5.3.8.tar.gz</p></blockquote>
<p>平时在忙工作就没细究，直到今天在v2ex看到有朋友提出了这个问题，参考了回帖中提及的<a href="http://psionides.eu/2008/06/30/ls-on-mac-and-extended-file-attributes/">资料</a>做了此份笔记。</p>
<p><strong>它是什么</strong></p>
<p>文件的扩展属性标记</p>
<ul>
<li>存放文件的元数据信息，存储在HFS文件系统内</li>
<li>常规浏览时不可见</li>
<li>许多流行的文件系统都支持这类元数据</li>
<li>除了@，还有+，表明文件拥有非标准的权限集，这些权限集在一些ACLs系统中使用</li>
<li>查看元数据属性的方式 ls -@ 即可。<br />
注：com.apple.quarantine 属性表面文件是从互联网下载到本地的，在首次打开文件时候会弹出提示框要求用户是否确认要打开此文件，如果选“是”，此属性即被清除</li>
</ul>
<p><strong>如何管理</strong></p>
<p>xattr用于访问和管理这些元数据，用法如下：</p>
<ul>
<li>xattr &lt;file&gt; 打印元数据</li>
<li>xattr -l &lt;file&gt; 打印详细的元数据信息，如：文件下载工具、下载时间</li>
<li>xattr -w &lt;attr&gt; &lt;file&gt; 新增元数据</li>
<li>xattr -d &lt;attr&gt; &lt;file&gt; 删除元数据</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/12/macos-%e4%b8%ad%e7%9a%84%e6%89%a9%e5%b1%95%e5%b1%9e%e6%80%a7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>修正招行专业版客户端在 Windows 7 中乱码的问题（Parallels Desktop）</title>
		<link>http://zhengwei.name/2011/11/%e4%bf%ae%e6%ad%a3%e6%8b%9b%e8%a1%8c%e4%b8%93%e4%b8%9a%e7%89%88%e5%ae%a2%e6%88%b7%e7%ab%af%e5%9c%a8-windows-7-%e4%b8%ad%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98%ef%bc%88parallels-desktop%ef%bc%89/</link>
		<comments>http://zhengwei.name/2011/11/%e4%bf%ae%e6%ad%a3%e6%8b%9b%e8%a1%8c%e4%b8%93%e4%b8%9a%e7%89%88%e5%ae%a2%e6%88%b7%e7%ab%af%e5%9c%a8-windows-7-%e4%b8%ad%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98%ef%bc%88parallels-desktop%ef%bc%89/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 03:56:04 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Mac OS]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=256</guid>
		<description><![CDATA[平台 Windows 7 简体中文版，基于 Parallels Desktop 问题一：安装过程、登录界面及菜单乱码 控制面版 -&#62; 时钟语言区域 -&#62; 更改显示语言 -&#62; 切换为“管理”标签 -&#62; 在非Unicode程序的语言中点击“更改系统区域设置”改为“中文（简体 中国）” -&#62; 确定 -&#62; 重新启动电脑 -&#62; 重新安专业版网银 问题二：转账过程中提醒时间错误 控制面板 -&#62; 区域设置 -&#62; 将时间格式从 yyyy/mm/dd 修改为 yyyy-mm-dd 原文：http://blog.sina.com.cn/s/blog_549097390100qaf2.html]]></description>
			<content:encoded><![CDATA[<p><strong>平台</strong></p>
<p>Windows 7 简体中文版，基于 Parallels Desktop</p>
<p><strong>问题一：安装过程、登录界面及菜单乱码</strong></p>
<p>控制面版 -&gt; 时钟语言区域 -&gt; 更改显示语言 -&gt; 切换为“管理”标签 -&gt; 在非Unicode程序的语言中点击“更改系统区域设置”改为“中文（简体 中国）” -&gt; 确定 -&gt; 重新启动电脑 -&gt; 重新安专业版网银</p>
<p><strong>问题二：转账过程中提醒时间错误</strong></p>
<p>控制面板 -&gt; 区域设置 -&gt; 将时间格式从 yyyy/mm/dd 修改为 yyyy-mm-dd</p>
<p>原文：http://blog.sina.com.cn/s/blog_549097390100qaf2.html</p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/11/%e4%bf%ae%e6%ad%a3%e6%8b%9b%e8%a1%8c%e4%b8%93%e4%b8%9a%e7%89%88%e5%ae%a2%e6%88%b7%e7%ab%af%e5%9c%a8-windows-7-%e4%b8%ad%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98%ef%bc%88parallels-desktop%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>launchctl 笔记</title>
		<link>http://zhengwei.name/2011/11/lanunchctl-notes/</link>
		<comments>http://zhengwei.name/2011/11/lanunchctl-notes/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 05:54:26 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Mac OS]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=254</guid>
		<description><![CDATA[相关目录 /System/Library/LaunchDaemons 操作系统，用户登录前生效，以 root 身份执行任务 /System/Library/LaunchAgents 操作系统，用户登录后生效，以 root 身份执行任务 /Library/LaunchDaemons 系统管理员，用户登录前生效，以 root 身份执行任务 /Library/LaunchAgents 系统管理员，用户登录后生效，以 root 身份执行任务 ~/Library/LaunchAgents 当前用户，用户登录后生效，以当前登录用户身份执行任务 使任务生效 将 plist 文件按需要放置在上文的相关目录中 launchctl load &#60;plist path&#62; 执行上述操作后任务会立即生效，且重启系统后也会自动生效。如果 plist 没有放在指定的目录，重启系统后不会再生效。 如果 plist 存在 Key Disabled，且其值为 true，launchctl load 会提示 nothing found to load，系统启动时也不会自动生效人物，如果要手动强制启动，忽略 &#8230; <a href="http://zhengwei.name/2011/11/lanunchctl-notes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>相关目录</strong></p>
<ul>
<li>/System/Library/LaunchDaemons 操作系统，用户登录前生效，以 root 身份执行任务</li>
<li>/System/Library/LaunchAgents 操作系统，用户登录后生效，以 root 身份执行任务</li>
<li>/Library/LaunchDaemons 系统管理员，用户登录前生效，以 root 身份执行任务</li>
<li>/Library/LaunchAgents 系统管理员，用户登录后生效，以 root 身份执行任务</li>
<li>~/Library/LaunchAgents 当前用户，用户登录后生效，以当前登录用户身份执行任务</li>
</ul>
<p><strong>使任务生效</strong></p>
<ol>
<li>将 plist 文件按需要放置在上文的相关目录中</li>
<li>launchctl load &lt;plist path&gt;</li>
</ol>
<p>执行上述操作后任务会立即生效，且重启系统后也会自动生效。如果 plist 没有放在指定的目录，重启系统后不会再生效。</p>
<p>如果 plist 存在 Key Disabled，且其值为 true，launchctl load 会提示 nothing found to load，系统启动时也不会自动生效人物，如果要手动强制启动，忽略 Disabled 为 true 带来的影响，传递 -wF 参数给 launchctl 即可。</p>
<p><strong>使任务失效</strong></p>
<ol>
<li>launchctl unload &lt;plist path&gt;</li>
<li>将相关 plist 文件从原有目录中移除</li>
</ol>
<p>执行上述操作后，任务会立即失效，plist 文件不会被移除，但是如果不将其从相关目录移走的话，重启系统后任务仍然会自动生效。</p>
<p>plist 文件范例</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;name.zhengwei.test&lt;/string&gt;

  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;/Users/Wayne/Desktop/test.sh&lt;/string&gt;
  &lt;/array&gt;

  &lt;key&gt;Nice&lt;/key&gt;
  &lt;integer&gt;1&lt;/integer&gt;

  &lt;key&gt;StartInterval&lt;/key&gt;
  &lt;integer&gt;10&lt;/integer&gt;

  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;

  &lt;key&gt;StandardErrorPath&lt;/key&gt;
  &lt;string&gt;/tmp/test.err&lt;/string&gt;

  &lt;key&gt;StandardOutPath&lt;/key&gt;
  &lt;string&gt;/tmp/test.out&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;</pre>
<ul>
<li>XML 节点层级为 plist &gt; dict &gt; key / value</li>
<li>key /value 以节点的形式交替出现，value 支持的数据格式有 integer、string、array、true、false 等等</li>
<li>Label、Program和ProgramArguments 三个 Key 必须存在</li>
<li>Program 为要启动的应用程序或脚本路径</li>
<li>ProgramArguments 为传给依次传给 Program 的参数集合</li>
</ul>
<p><strong>参考链接</strong></p>
<ul>
<li><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/launchd.8.html">launchctl 手册</a></li>
<li><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html">plist 文档</a></li>
</ul>
<p><span style="color: #000000;"><strong>2012.03.08更新：</strong></span></p>
<h3><span style="color: #000000;"><strong>以root身份运行</strong></span></h3>
<p>在设置nginx时候发现一直无法绑定80端口，反复尝试后发现以root身份运行job和plist放在哪层的LaunchAgents or LaunchDeamons无关，关键在于如果手动load plist的时候必须用sudo。另外，如果要sudo launchctl load 的话，plist文件的ownership要是root，否则是有一个消息提示：Dobious ownership on file&#8230;</p>
<p>要随机启动必须放在/System/Library/LaunchDaemons或/Library/LaunchDaemons之下，原因是因为LaunchAgents下的plist都会以当前登录用户的身份load进来……</p>
<p>总结出来就是，如果你的job需要以root身份运行饼随机启动，只要将它的plist文件放置在上述的任意LaunchDaemons目录下，并指定其ownership为root后通过sudo launchctl load &lt;plist-file&gt;即可。</p>
<p>参考：</p>
<ul>
<li><a href="http://superuser.com/questions/36087/how-do-i-run-a-launchd-command-as-root">How do I run a launchd command as root</a></li>
<li><a href="http://hintsforums.macworld.com/archive/index.php/t-121860.html">Scheduling application using launchctl for logged in user</a></li>
</ul>
<h3><strong>Daemon的反复启动问题</strong></h3>
<p>设定nginx登录后自启动后发现，由于缺省情况下是生成子进程后父进程立即退出，导致launchctl在KeepAlive配置的作用下反复启动nginx，产生了很多错误信息，所以在设置守护进程的时候要注意规避这类问题，nginx可以通过设置daemon off;或者去除掉KeepAlive设置来解决。</p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/11/lanunchctl-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>centos上如何yum安装git?</title>
		<link>http://zhengwei.name/2011/11/centos%e4%b8%8a%e5%a6%82%e4%bd%95yum%e5%ae%89%e8%a3%85git/</link>
		<comments>http://zhengwei.name/2011/11/centos%e4%b8%8a%e5%a6%82%e4%bd%95yum%e5%ae%89%e8%a3%85git/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 05:40:22 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=250</guid>
		<description><![CDATA[需要先添加EPEL(Extra Packages for Enterprise Linux) repository： rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm 然后使用yum安装即可： yum install git From：http://51hired.com/questions/13038/centos%E4%B8%8A%E5%A6%82%E4%BD%95yum%E5%AE%89%E8%A3%85git 参考：什么是EPEL]]></description>
			<content:encoded><![CDATA[<p>需要先添加EPEL(Extra Packages for Enterprise Linux) repository：</p>
<blockquote><p>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm</p></blockquote>
<p>然后使用yum安装即可：</p>
<blockquote><p>yum install git</p></blockquote>
<p>From：http://51hired.com/questions/13038/centos%E4%B8%8A%E5%A6%82%E4%BD%95yum%E5%AE%89%E8%A3%85git</p>
<p>参考：<a href="http://fedoraproject.org/wiki/EPEL">什么是EPEL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/11/centos%e4%b8%8a%e5%a6%82%e4%bd%95yum%e5%ae%89%e8%a3%85git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给 git push 和 git pull 设置默认仓库</title>
		<link>http://zhengwei.name/2011/10/%e7%bb%99-git-push-%e5%92%8c-git-pull-%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e4%bb%93%e5%ba%93/</link>
		<comments>http://zhengwei.name/2011/10/%e7%bb%99-git-push-%e5%92%8c-git-pull-%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e4%bb%93%e5%ba%93/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 06:02:34 +0000</pubDate>
		<dc:creator>Wayne</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://zhengwei.name/?p=248</guid>
		<description><![CDATA[git config &#8211;global branch.master.remote origin git config &#8211;global branch.master.merge refs/heads/master 参考： git pull的默认地址 How do you get git to always pull from a specific branch?]]></description>
			<content:encoded><![CDATA[<p>git config &#8211;global branch.master.remote origin<br />
git config &#8211;global branch.master.merge refs/heads/master</p>
<p>参考：<br />
<a href="http://www.cnblogs.com/lbsx/archive/2010/10/16/1853193.html">git pull的默认地址</a><br />
<a href="http://stackoverflow.com/questions/658885/how-do-you-get-git-to-always-pull-from-a-specific-branch">How do you get git to always pull from a specific branch?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zhengwei.name/2011/10/%e7%bb%99-git-push-%e5%92%8c-git-pull-%e8%ae%be%e7%bd%ae%e9%bb%98%e8%ae%a4%e4%bb%93%e5%ba%93/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

