{"id":5904,"date":"2013-11-30T17:05:36","date_gmt":"2013-11-30T09:05:36","guid":{"rendered":"http:\/\/jpuyy.com\/?p=5904"},"modified":"2013-12-17T17:37:29","modified_gmt":"2013-12-17T09:37:29","slug":"linux-nice","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=5904","title":{"rendered":"linux nice\u547d\u4ee4"},"content":{"rendered":"<p>nice\u547d\u4ee4\u7528\u4e8e\u8c03\u6574\u7a0b\u5e8f\u7684\u4f18\u5148\u7ea7\uff0c\u5728top\u547d\u4ee4\u4e2d\u770b\u5230\u7684\u7b2c\u4e09\u5217 NI \u3002<\/p>\n<p>\u7cfb\u7edf\u7684\u4f18\u5148\u7ea7\u8303\u56f4\u4e3a-20(\u6700\u9ad8)\u81f319(\u6700\u4f4e)\uff0c\u9ed8\u8ba4\u4f18\u5148\u7ea7\u4e3a0\uff0c\u53ea\u6709root\u7528\u6237\u624d\u53ef\u4ee5\u6307\u5b9a0\u4ee5\u4e0b\u7684\u4f18\u5148\u7ea7\u3002<\/p>\n<p>\u5982\u5c06mysqld\u4ee5-3\u4f18\u5148\u7ea7\uff0c\u5219\u8fd0\u884c<\/p>\n<pre>nice -n -3 \/usr\/sbin\/mysqld &amp;<\/pre>\n<p>top\u68c0\u67e5<\/p>\n<pre>PID \u3000USER \u3000PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND \r\n30128 mysql 17 -3 665m 42m 6740 S 0 0.5 0:00.09 mysqld<\/pre>\n<p>\u771f\u6b63\u7684\u4f18\u5148\u7ea7\u662f\u6309PR+NI\u7684\u503c\uff0c\u8fd9\u4e2a\u503c\u8d8a\u5c0f\uff0c\u8d8a\u4f18\u5148\u3002<\/p>\n<p>\u5982\u679c-n\u540e\u4e0d\u52a0\u5177\u4f53\u7ea7\u522b\u7684\u8bdd\uff0c\u9ed8\u8ba4\u662f10\uff0c\u5373\u4ee510 nice\u503c\u8fd0\u884c\u3002<\/p>\n<p>\u4e0a\u9762\u662f\u5f00\u59cb\u6267\u884c\u547d\u4ee4\u7684\u65f6\u5019\u6307\u5b9anice\u503c\uff0c\u5982\u679c\u7a0b\u5e8f\u5df2\u7ecf\u5728\u8fd0\u884c\uff0c\u5219\u4f7f\u7528renice\u6765\u8c03\u6574nice\u503c\u3002<\/p>\n<p>\u5982\u4e0a\u9762mysqld\u8fd0\u884c\u7684nice\u503c\u662f-3,\u8fdb\u7a0b\u53f7\u662f30128\uff0c\u73b0\u5728\u6307\u5b9a\u4e3a-11<\/p>\n<pre># renice -11 -p 30128\r\n30128 (process ID) old priority -3, new priority -11<\/pre>\n<p>\u5728top\u4e2d\u8c03\u6574nice\u503c\u5f88\u662f\u65b9\u4fbf\uff0c\u8fdb\u5165top\u540e\u6309&#8221;r&#8221;&#8211;&gt;\u8f93\u5165\u8fdb\u7a0bPID&#8211;&gt;\u8f93\u5165nice\u503c\uff0c\u5982<\/p>\n<pre>PID to renice:30128\uff08\u56de\u8f66\uff09\r\nRenice PID 30128 to value: -11(nice\u503c)<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nice\u547d\u4ee4\u7528\u4e8e\u8c03\u6574\u7a0b\u5e8f\u7684\u4f18\u5148\u7ea7\uff0c\u5728top\u547d\u4ee4\u4e2d\u770b\u5230\u7684\u7b2c\u4e09\u5217 NI \u3002 \u7cfb\u7edf\u7684\u4f18\u5148\u7ea7\u8303\u56f4\u4e3a-20(\u6700\u9ad8)\u81f319(\u6700\u4f4e)\uff0c\u9ed8\u8ba4\u4f18\u5148\u7ea7\u4e3a0\uff0c\u53ea\u6709root\u7528\u6237\u624d\u53ef\u4ee5\u6307\u5b9a0\u4ee5\u4e0b\u7684\u4f18\u5148\u7ea7\u3002 \u5982\u5c06mysqld\u4ee5-3\u4f18\u5148\u7ea7\uff0c\u5219\u8fd0\u884c nice -n -3 \/usr\/sbin\/mysqld &amp; top\u68c0\u67e5 PID \u3000USER \u3000PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30128 mysql 17 -3 665m 42m 6740 S 0 0.5 0:00.09 mysqld \u771f\u6b63\u7684\u4f18\u5148\u7ea7\u662f\u6309PR+NI\u7684\u503c\uff0c\u8fd9\u4e2a\u503c\u8d8a\u5c0f\uff0c\u8d8a\u4f18\u5148\u3002 \u5982\u679c-n\u540e\u4e0d\u52a0\u5177\u4f53\u7ea7\u522b\u7684\u8bdd\uff0c\u9ed8\u8ba4\u662f10\uff0c\u5373\u4ee510 nice\u503c\u8fd0\u884c\u3002 \u4e0a\u9762\u662f\u5f00\u59cb\u6267\u884c\u547d\u4ee4\u7684\u65f6\u5019\u6307\u5b9anice\u503c\uff0c\u5982\u679c\u7a0b\u5e8f\u5df2\u7ecf\u5728\u8fd0\u884c\uff0c\u5219\u4f7f\u7528renice\u6765\u8c03\u6574nice\u503c\u3002 \u5982\u4e0a\u9762mysqld\u8fd0\u884c\u7684nice\u503c\u662f-3,\u8fdb\u7a0b\u53f7\u662f30128\uff0c\u73b0\u5728\u6307\u5b9a\u4e3a-11 # renice -11 -p 30128 30128 (process ID) old priority -3, new priority -11 \u5728top\u4e2d\u8c03\u6574nice\u503c\u5f88\u662f\u65b9\u4fbf\uff0c\u8fdb\u5165top\u540e\u6309&#8221;r&#8221;&#8211;&gt;\u8f93\u5165\u8fdb\u7a0bPID&#8211;&gt;\u8f93\u5165nice\u503c\uff0c\u5982 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-5904","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5904"}],"version-history":[{"count":7,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5904\/revisions"}],"predecessor-version":[{"id":5928,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5904\/revisions\/5928"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}