{"id":59,"date":"2014-11-01T22:09:15","date_gmt":"2014-11-01T14:09:15","guid":{"rendered":"http:\/\/www.zhuyanbin.com\/?p=59"},"modified":"2014-11-01T22:09:15","modified_gmt":"2014-11-01T14:09:15","slug":"mac-os%e5%90%af%e5%8a%a8%e6%9c%8d%e5%8a%a1%e4%bc%98%e5%8c%96%e9%ab%98%e7%ba%a7%e7%af%87","status":"publish","type":"post","link":"https:\/\/www.yanbin888.com\/?p=59","title":{"rendered":"Mac OS\u542f\u52a8\u670d\u52a1\u4f18\u5316\u9ad8\u7ea7\u7bc7"},"content":{"rendered":"<p>Mac\u4e0b\u7684\u542f\u52a8\u670d\u52a1\u4e3b\u8981\u6709\u4e09\u4e2a\u5730\u65b9\u53ef\u914d\u7f6e\uff1a<\/p>\n<p>1\uff0c\u7cfb\u7edf\u504f\u597d\u8bbe\u7f6e-&gt;\u5e10\u6237-&gt;\u767b\u9646\u9879<\/p>\n<p>2\uff0c\/System\/Library\/StartupItems \u548c \/Library\/StartupItems\/<\/p>\n<p>3\uff0claunchd \u7cfb\u7edf\u521d\u59cb\u5316\u8fdb\u7a0b\u914d\u7f6e\u3002<\/p>\n<p>\u524d\u4e24\u79cd\u4f18\u5316\u6bd4\u8f83\u7b80\u5355\uff0c\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u7684\u662f\u7b2c\u4e09\u79cd\u66f4\u4e3a\u590d\u6742\u7684launchd\u914d\u7f6e\u4f18\u5316\u3002<\/p>\n<p>launchd\u662fMac OS\u4e0b\uff0c\u7528\u4e8e\u521d\u59cb\u5316\u7cfb\u7edf\u73af\u5883\u7684\u5173\u952e\u8fdb\u7a0b\u3002\u7c7b\u4f3cLinux\u4e0b\u7684init, rc\u3002<\/p>\n<p>\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e0bMac OS X\u7684\u542f\u52a8\u539f\u7406\uff1a<\/p>\n<p>1\uff0cmac\u56fa\u4ef6\u6fc0\u6d3b\uff0c\u521d\u59cb\u5316\u786c\u4ef6\uff0c\u52a0\u8f7dBootX\u5f15\u5bfc\u5668\u3002<\/p>\n<p>2\uff0cBootX\u52a0\u8f7d\u5185\u6838\u4e0e\u5185\u6838\u6269\u5c55(kext)\u3002<\/p>\n<p>3\uff0c\u5185\u6838\u542f\u52a8launchd\u8fdb\u7a0b\u3002<\/p>\n<p>4\uff0claunchd\u6839\u636e \/System\/Library\/LaunchAgents , \/System\/Library\/LaunchDaemons , \/Library\/LaunchDaemons, Library\/LaunchAgents , ~\/Library\/LaunchAgents \u91cc\u7684plist\u914d\u7f6e\uff0c\u542f\u52a8\u670d\u52a1\u5b88\u62a4\u8fdb\u7a0b\u3002<\/p>\n<p>\u770b\u5b8c\u4e86Mac OS X\u7684\u542f\u52a8\u539f\u7406\uff0c\u6211\u4eec\u4e0d\u96be\u53d1\u89c9 \/System\/Library\/LaunchAgents , \/System\/Library\/LaunchDaemons , \/Library\/LaunchDaemons, Library\/LaunchAgents \u4e94\u4e2a\u76ee\u5f55\u4e0b\u7684plist\u5c5e\u6027\u6587\u4ef6\u662f\u4f18\u5316\u7cfb\u7edf\u7684\u5173\u952e\u3002<\/p>\n<p>\u4e0b\u9762\u518d\u6765\u7406\u89e3\u51e0\u4e2a\u57fa\u7840\u6982\u5ff5\uff1a<\/p>\n<p>\/System\/Library\u548c\/Library\u548c~\/Library\u76ee\u5f55\u7684\u533a\u522b?<\/p>\n<p>\/System\/Library\u76ee\u5f55\u662f\u5b58\u653eApple\u81ea\u5df1\u5f00\u53d1\u7684\u8f6f\u4ef6\u3002<\/p>\n<p>\/Library\u76ee\u5f55\u662f\u7cfb\u7edf\u7ba1\u7406\u5458\u5b58\u653e\u7684\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u3002<\/p>\n<p>~\/Library\/\u662f\u7528\u6237\u81ea\u5df1\u5b58\u653e\u7684\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u3002<\/p>\n<p>LaunchDaemons\u548cLaunchAgents\u7684\u533a\u522b?<\/p>\n<p>LaunchDaemons\u662f\u7528\u6237\u672a\u767b\u9646\u524d\u5c31\u542f\u52a8\u7684\u670d\u52a1(\u5b88\u62a4\u8fdb\u7a0b)\u3002<\/p>\n<p>LaunchAgents\u662f\u7528\u6237\u767b\u9646\u540e\u542f\u52a8\u7684\u670d\u52a1(\u5b88\u62a4\u8fdb\u7a0b)\u3002<\/p>\n<p>\u4e0a\u9762\u63d0\u5230\u7684\u4e94\u4e2a\u76ee\u5f55\u4e0b\u7684plist\u6587\u4ef6\u683c\u5f0f\u53ca\u6bcf\u4e2a\u5b57\u6bb5\u7684\u542b\u4e49\uff1a<\/p>\n<table cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"middle\"><strong>Key<\/strong><\/td>\n<td valign=\"middle\"><strong>Description<\/strong><\/td>\n<td valign=\"middle\"><strong>Required<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">Label<\/td>\n<td valign=\"middle\">The name of the job<\/td>\n<td valign=\"middle\">yes<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">ProgramArguments<\/td>\n<td valign=\"middle\">Strings to pass to the program when it is executed<\/td>\n<td valign=\"middle\">yes<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">UserName<\/td>\n<td valign=\"middle\">The job will be run as the given user, who may not necessarily be the one who submitted it to launchd.<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">inetdCompatibility<\/td>\n<td valign=\"middle\">Indicates that the daemon expects to be run as if it were launched by inetd<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">Program<\/td>\n<td valign=\"middle\">The path to your executable. This key can save the ProgramArguments key for flags and arguments.<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">onDemand<\/td>\n<td valign=\"middle\">A boolean flag that defines if a job runs continuously or not<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">RootDirectory<\/td>\n<td valign=\"middle\">The job will be chrooted into another directory<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">ServiceIPC<\/td>\n<td valign=\"middle\">Whether the daemon can speak IPC to launchd<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">WatchPaths<\/td>\n<td valign=\"middle\">Allows launchd to start a job based on modifications at a file-system path<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">QueueDirectories<\/td>\n<td valign=\"middle\">Similar to WatchPath, a queue will only watch an empty directory for new files<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">StartInterval<\/td>\n<td valign=\"middle\">Used to schedule a job that runs on a repeating schedule. Specified as the number of seconds to wait between runs.<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">StartCalendarInterval<\/td>\n<td valign=\"middle\">Job scheduling. The syntax is similar to cron.<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">HardResourceLimits<\/td>\n<td valign=\"middle\">Controls restriction of the resources consumed by any job<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">LowPriorityIO<\/td>\n<td valign=\"middle\">Tells the kernel that this task is of a low priority when doing file system I\/O<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<tr>\n<td valign=\"middle\">Sockets<\/td>\n<td valign=\"middle\">An array can be used to specify what socket the daemon will listen on for launch on demand<\/td>\n<td valign=\"middle\">no<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u770b\u4e0d\u61c2\u4e0a\u9762\u5730plist\u914d\u7f6e\u5417?\u6ca1\u5173\u7cfb\uff0c\u6211\u4eec\u7684\u4f18\u5316\u7b56\u7565\u662f\u5b8c\u5168\u5378\u8f7d\u670d\u52a1\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u7528\u5173\u5fc3plist\u91cc\u7684\u914d\u7f6e\u542b\u4e49\u3002<\/p>\n<p>\u5f00\u59cb\u4f18\u5316\u7981\u7528\u670d\u52a1\uff0c\u6211\u4eec\u9700\u8981\u7528\u5230Mac OS\u63d0\u4f9b\u7684\u4e00\u4e2a\u5de5\u5177\u6307\u4ee4-launchctl<\/p>\n<p>launchctl \u6307\u4ee4\u4f1a\u9488\u5bf9\u670d\u52a1\u8bbe\u7f6e\u4e00\u4e2a\u7981\u7528\u6807\u5fd7\uff0claunchd\u542f\u52a8\u65f6\u4f1a\u5148\u68c0\u67e5\u8fd9\u4e2a\u670d\u52a1\u662f\u5426\u88ab\u7981\u7528\uff0c\u4ece\u800c\u786e\u5b9a\u662f\u5426\u9700\u8981\u542f\u7528\u8fd9\u4e2a\u670d\u52a1\u3002<\/p>\n<p>\u7981\u7528\u670d\u52a1\u7684\u65b9\u6cd51<\/p>\n<p>\u5148\u627e\u5230\u7981\u7528\u6807\u5fd7\u6587\u4ef6 \/var\/db\/launchd.db\/com.apple.launchd\/overrides.plist\uff0c\u67e5\u770b\u4f60\u8981\u7981\u7528\u7684\u670d\u52a1\u662f\u5426\u5df2\u88ab\u7981\u7528\u4e86\u3002<\/p>\n<p>\u6709\u4e9b\u670d\u52a1\u5df2\u88ab\u7981\u7528\uff0c\u4f46\u672a\u5217\u5728overrides.plist\u91cc\u3002\u6b64\u65f6\uff0c\u4f60\u8fd8\u9700\u8981\u68c0\u67e5\u8fd9\u4e2a\u670d\u52a1\u7684plist\u6587\u4ef6Label\u5b57\u6bb5\u662f\u5426\u5df2\u7ecf\u6807\u8bb0\u4e3a Disable\u3002<\/p>\n<p>\u786e\u8ba4\u8fd9\u4e2a\u670d\u52a1\u672a\u7981\u7528\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u5982\u4e0b\u547d\u4ee4\uff0c\u6765\u7981\u7528\u670d\u52a1\uff1a<\/p>\n<p>sudo launchctl unload plist\u6587\u4ef6\u8def\u5f84<\/p>\n<p>sudo launchctl unload -w plist\u6587\u4ef6\u8def\u5f84<\/p>\n<p>\u6bd4\u5982\uff0c\u6211\u60f3\u7981\u7528spotlight\uff0c\u5219\u8f93\u5165<\/p>\n<p>sudo launchctl unload \/System\/Library\/LaunchAgents\/com.apple.Spotlight.plist<\/p>\n<p>sudo launchctl unload -w \/System\/Library\/LaunchAgents\/com.apple.Spotlight.plist<\/p>\n<p>\u7981\u7528\u5b8c\u670d\u52a1\u4ee5\u540e\uff0c\u91cd\u542fMac OS\u5373\u53ef\u751f\u6548\u3002<\/p>\n<p>\u7981\u7528\u670d\u52a1\u7684\u65b9\u6cd52\uff0c\u4e00\u79cd\u66f4\u6709\u6548\u4e14\u66b4\u529b\u7684\u65b9\u6cd5(\u63a8\u8350)<\/p>\n<p>\u5148\u5378\u8f7d\u670d\u52a1<\/p>\n<p>sudo launchctl unload \/System\/Library\/LaunchAgents\/com.apple.Spotlight.plist<\/p>\n<p>\u7136\u540e\u5c06plist\u6587\u4ef6mv\u5230\u5176\u4ed6\u76ee\u5f55\u5907\u4efd\u3002\u91cd\u542f\u3002\u641e\u5b9a\u3002\u662f\u4e0d\u662f\u5f88\u7b80\u5355!<\/p>\n<p>\u6211\u4e2a\u4eba\u6bd4\u8f83\u559c\u6b22\u8fd9\u79cd\u7981\u7528\u670d\u52a1\u7684\u65b9\u5f0f\uff0c\u6240\u4ee5\u63a8\u8350\u4e00\u4e0b\u3002<\/p>\n<p>\u5982\u679c\u53d1\u73b0\u670d\u52a1\u7981\u7528\u540e\uff0c\u7cfb\u7edf\u6216\u8f6f\u4ef6\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\uff0c\u8fd8\u539f\u670d\u52a1\uff1a<\/p>\n<p>\u65b9\u6cd51:<\/p>\n<p>sudo launchctl load -wF plist\u6587\u4ef6\u8def\u5f84<\/p>\n<p>\u65b9\u6cd52:<\/p>\n<p>\u5c06\u5907\u4efd\u7684plist\u6587\u4ef6mv\u56de\u539f\u6765\u7684\u6587\u4ef6\u5939\u3002<\/p>\n<p>sudo launchctl load plist\u6587\u4ef6\u8def\u5f84<\/p>\n<p>\u6ce8\u610f\uff1a\u7cfb\u7edf\u7ea7\u670d\u52a1\u7684\u7981\u7528\u8981\u5f02\u5e38\u5c0f\u5fc3\uff0c\u8bf7\u5728\u7981\u7528\u524dgoogle\uff0c\u786e\u4fdd\u4f60\u719f\u77e5\u8fd9\u4e2a\u670d\u52a1\u7684\u4f5c\u7528\u3002\u5426\u5219\u53ef\u80fd\u5bfc\u81f4\u7cfb\u7edf\u65e0\u6cd5\u542f\u52a8\u3002<\/p>\n<p>\u6700\u5b89\u5168\u7684\u505a\u6cd5\u5c31\u662f\u4e0d\u8981\u53bb\u7981\u7528\u5b83\u4e86\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u7528\u6237\u670d\u52a1\u6211\u4eec\u8fd8\u662f\u53ef\u4ee5\u653e\u5fc3\u7981\u7528\u7684\uff0c\u6709\u95ee\u9898\u6700\u591a\u518d\u542f\u7528\u5457\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u7981\u7528\u7684\u670d\u52a1\u5217\u8868\uff1a<\/p>\n<p>\/System\/Library\/LaunchDaemons\/com.apple.metadata.mds.plist (\u7981\u7528spotlight\u7684\u524d\u63d0)<\/p>\n<p>\/System\/Library\/LaunchAgents\/com.apple.Spotlight.plist (Spotlight)<\/p>\n<p>\/Library\/LaunchDaemons\/com.google.keystone.daemon.plist (Google Software Update)<\/p>\n<p>\/Library\/LaunchAgents\/com.google.keystone.root.agent (Google Software Update)<\/p>\n<p>~\/Library\/LaunchAgents\/com.google.keystone.agent.plist (Google Software Update\uff0c\u7528\u6237\u4e0b\u7684\u8fdb\u7a0b\u4e0d\u9700\u8981\u52a0 sudo)<\/p>\n<p>~\/Library\/LaunchAgents\/com.apple.CSConfigDotMacCert-ken.wug@me.com-SharedServices.Agent.plist (me.com\u7684\u5171\u4eab\u670d\u52a1\uff0c\u6211\u4e0d\u7528)<\/p>\n<p>\/System\/Library\/LaunchDaemons\/org.cups.cupsd.plist (\u6253\u5370\u673a)<\/p>\n<p>\/System\/Library\/LaunchDaemons\/org.cups.cups-lpd.plist (\u6253\u5370\u673a)<\/p>\n<p>\/System\/Library\/LaunchDaemons\/com.apple.blued.plist (\u84dd\u7259)<\/p>\n<p>\/System\/Library\/LaunchAgents\/com.apple.AirPortBaseStationAgent.plist (apple\u65e0\u7ebf\u57fa\u7ad9\uff0c\u6211\u6ca1\u6709\u8fd9\u4e2a\u8bbe\u5907)<\/p>\n<p>\u77e5\u9053\u5b88\u62a4\u8fdb\u7a0b(\u670d\u52a1)\u540d\uff0c\u5982\u4f55\u627e\u5230\u5bf9\u5e94\u7684plist\u6587\u4ef6?<\/p>\n<p>\u5c06\u8fdb\u7a0b(\u670d\u52a1)\u540d\u62f7\u8d1d\uff0c\u7136\u540e\u5230 \/System\/Library\/LaunchAgents , \/System\/Library\/LaunchDaemons , \/Library\/LaunchDaemons, Library\/LaunchAgents , ~\/Library\/LaunchAgents \u4e94\u4e2a\u76ee\u5f55\u91cc\uff0c\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u627e\uff1a<\/p>\n<p>ll|grep \u8fdb\u7a0b(\u670d\u52a1)\u540d<\/p>\n<p>\u6bd4\u5982<\/p>\n<p>ll|grep blued<\/p>\n<p>\u5728 \/System\/Library\/LaunchDaemons \u4e2d\u627e\u5230\u4e86\u5b83\u3002\u63a5\u4e0b\u6765\uff0c\u8bf7\u6309\u4e0a\u9762\u6307\u5bfc\u7684\u6b65\u9aa4\uff0c\u7981\u7528\u8be5\u670d\u52a1\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>link:\u00a0<a title=\"http:\/\/www.3lian.com\/edu\/2013\/04-26\/67191.html\" href=\"http:\/\/www.3lian.com\/edu\/2013\/04-26\/67191.html\" target=\"_blank\">http:\/\/www.3lian.com\/edu\/2013\/04-26\/67191.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mac\u4e0b\u7684\u542f\u52a8\u670d\u52a1\u4e3b\u8981\u6709\u4e09\u4e2a\u5730\u65b9\u53ef\u914d\u7f6e\uff1a 1\uff0c\u7cfb\u7edf\u504f\u597d\u8bbe\u7f6e-&gt;\u5e10\u6237-&gt;\u767b\u9646\u9879 2\uff0c\/System\/ <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.yanbin888.com\/?p=59\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-mac","tag-mac-os-x"],"_links":{"self":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":1,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}