﻿{"id":836,"date":"2021-01-23T06:16:23","date_gmt":"2021-01-22T22:16:23","guid":{"rendered":"https:\/\/byy3.com\/?p=836"},"modified":"2021-01-23T06:16:23","modified_gmt":"2021-01-22T22:16:23","slug":"centos%e7%9a%84gnome%e6%a1%8c%e9%9d%a2%e9%ab%98cpu%e5%8d%a0%e7%94%a8%e7%8e%87%ef%bc%8c%e5%85%b3%e4%ba%8elinux%e6%9d%80%e6%ad%bb%e8%bf%9b%e7%a8%8b%e7%9a%84%e9%82%a3%e4%ba%9b%e4%ba%8b","status":"publish","type":"post","link":"https:\/\/byy3.com\/?p=836","title":{"rendered":"centos\u7684gnome\u684c\u9762\u9ad8cpu\u5360\u7528\u7387\uff0c\u5173\u4e8elinux\u6740\u6b7b\u8fdb\u7a0b\u7684\u90a3\u4e9b\u4e8b"},"content":{"rendered":"<p>\u9996\u5148\uff0c\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u6240\u8c13\u7684\u201c\u50f5\u5c38\u8fdb\u7a0b\u201d\uff0c\u5e94\u786e\u4fdd\u5728\u6740\u6b7b\u7236\u8fdb\u7a0b\u4e4b\u524d\uff0c\u5148\u6740\u6b7b\u5176\u6240\u6709\u7684\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-837\" data-original=\"https:\/\/byy3.com\/wp-content\/uploads\/2021\/01\/2021012222150954.jpeg\" src=\"https:\/\/byy3.com\/wp-content\/themes\/MNews%20V2.4\/images\/post-loading.gif\" width=\"640\" height=\"382\" title=\"centos\u7684gnome\u684c\u9762\u9ad8cpu\u5360\u7528\u7387\uff0c\u5173\u4e8elinux\u6740\u6b7b\u8fdb\u7a0b\u7684\u90a3\u4e9b\u4e8b\u63d2\u56fe\" alt=\"centos\u7684gnome\u684c\u9762\u9ad8cpu\u5360\u7528\u7387\uff0c\u5173\u4e8elinux\u6740\u6b7b\u8fdb\u7a0b\u7684\u90a3\u4e9b\u4e8b\u63d2\u56fe\" \/><\/p>\n<p>centos<\/p>\n<p>ps -ef | grep gnome<\/p>\n<p>debian\u548cubuntu\u7684\u811a\u672c killpid.sh \u7ed3\u675fcpu\u5360\u6709\u7387\u524d4\u7684\u8fdb\u7a0b\u53ef\u80fd\u5bfc\u81f4\u90e8\u5206\u670d\u52a1\u65e0\u6cd5\u4f7f\u7528\u6bd4\u5982bt\u5b9d\u5854\u670d\u52a1\u9762\u677f\u7b49\u670d\u52a1<\/p>\n<p>\u9700\u8981\u91cd\u65b0\u670d\u52a1 \u5982systemctl restart cron<\/p>\n<pre>#!\/bin\/bash\r\nkill -9 `ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head | awk '{print $2}'`\r\n<\/pre>\n<p>\u5173\u4e8e\u5185\u5b58\u5360\u7528\u7387\u67e5\u770b\uff0c<b>\u67e5\u770b<\/b>RAM<b>\u4f7f\u7528<\/b>\u60c5\u51b5\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u547d\u4ee4\uff1acat \/proc\/meminfo\uff1b \u8fd9\u4e2a\u52a8\u6001\u66f4\u65b0\u7684\u865a\u62df\u6587\u4ef6\u5b9e\u9645\u4e0a\u662f\u8bb8\u591a\u5176\u4ed6<b>\u5185\u5b58<\/b>\u76f8\u5173\u5de5\u5177(\u5982\uff1afree \/ ps \/ top)\u7b49\u7684\u7ec4\u5408\u663e\u793a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-804\" data-original=\"https:\/\/byy3.com\/wp-content\/uploads\/2021\/01\/2021010700111063.jpg\" src=\"https:\/\/byy3.com\/wp-content\/themes\/MNews%20V2.4\/images\/post-loading.gif\" width=\"996\" height=\"679\" title=\"centos\u7684gnome\u684c\u9762\u9ad8cpu\u5360\u7528\u7387\uff0c\u5173\u4e8elinux\u6740\u6b7b\u8fdb\u7a0b\u7684\u90a3\u4e9b\u4e8b\u63d2\u56fe1\" alt=\"centos\u7684gnome\u684c\u9762\u9ad8cpu\u5360\u7528\u7387\uff0c\u5173\u4e8elinux\u6740\u6b7b\u8fdb\u7a0b\u7684\u90a3\u4e9b\u4e8b\u63d2\u56fe1\" \/><\/p>\n<div>\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u91ca\u653eCache Memory\uff1a<\/div>\n<div><\/div>\n<div>[rootmin@localhost~]#echo 3 &gt; \/proc\/sys\/vm\/drop_caches<\/div>\n<p>\u6216\u00a0 \u6e05\u9664\u7f13\u5b58\u811a\u672ccleanmem.sh<\/p>\n<pre>#!\/bin\/bash\r\n\r\nused=`free -m | awk 'NR==2' | awk '{print $3}'`\r\nfree=`free -m | awk 'NR==2' | awk '{print $4}'`\r\n\r\necho \"===========================\" &gt;&gt; \/var\/log\/mem.log\r\ndate &gt;&gt; \/var\/log\/mem.log\r\necho \"Memory usage | [Use\uff1a${used}MB][Free\uff1a${free}MB]\" &gt;&gt; \/var\/log\/mem.log\r\n\r\nif [ $free -le 100 ] ; then\r\nsync &amp;&amp; echo 1 &gt; \/proc\/sys\/vm\/drop_caches\r\nsync &amp;&amp; echo 2 &gt; \/proc\/sys\/vm\/drop_caches\r\nsync &amp;&amp; echo 3 &gt; \/proc\/sys\/vm\/drop_caches\r\necho \"OK\" &gt;&gt; \/var\/log\/mem.log\r\nelse\r\necho \"Not required\" &gt;&gt; \/var\/log\/mem.log\r\nfi\r\nexit<\/pre>\n<p>\u597d\u4e86<\/p>\n<hr \/>\n<p>\u6740\u6b7b\u8fdb\u7a0b\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u662f\u5355\u7eaf\u4f7f\u7528kill\u547d\u4ee4\u3002<\/p>\n<p>\u4f7f\u7528ps -ef\u547d\u4ee4\u786e\u5b9a\u8981\u6740\u6b7b\u8fdb\u7a0b\u7684PID\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p># kill -pid<\/p>\n<p>\u6ce8\u91ca\uff1a\u6807\u51c6\u7684kill\u547d\u4ee4\u901a\u5e38\u90fd\u80fd\u8fbe\u5230\u76ee\u7684\u3002\u7ec8\u6b62\u6709\u95ee\u9898\u7684\u8fdb\u7a0b\uff0c\u5e76\u628a\u8fdb\u7a0b\u7684\u8d44\u6e90\u91ca\u653e\u7ed9\u7cfb\u7edf\u3002\u7136\u800c\uff0c\u5982\u679c\u8fdb\u7a0b\u542f\u52a8\u4e86\u5b50\u8fdb\u7a0b\uff0c\u53ea\u6740\u6b7b\u7236\u8fdb\u7a0b\uff0c\u5b50\u8fdb\u7a0b\u4ecd\u5728\u8fd0\u884c\uff0c\u56e0\u6b64\u4ecd\u6d88\u8017\u8d44\u6e90\u3002<\/p>\n<p>\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u6240\u8c13\u7684\u201c\u50f5\u5c38\u8fdb\u7a0b\u201d\uff0c\u5e94\u786e\u4fdd\u5728\u6740\u6b7b\u7236\u8fdb\u7a0b\u4e4b\u524d\uff0c\u5148\u6740\u6b7b\u5176\u6240\u6709\u7684\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p>*\u786e\u5b9a\u8981\u6740\u6b7b\u8fdb\u7a0b\u7684PID\u6216PPID<\/p>\n<p># ps -ef | grep httpd<\/p>\n<p>*\u4ee5\u4f18\u96c5\u7684\u65b9\u5f0f\u7ed3\u675f\u8fdb\u7a0b<\/p>\n<p># kill -l PID<\/p>\n<p>-l\u9009\u9879\u544a\u8bc9kill\u547d\u4ee4\u7528\u597d\u50cf\u542f\u52a8\u8fdb\u7a0b\u7684\u7528\u6237\u5df2\u6ce8\u9500\u7684\u65b9\u5f0f\u7ed3\u675f\u8fdb\u7a0b\u3002\u5f53\u4f7f\u7528\u8be5\u9009\u9879\u65f6\uff0ckill\u547d\u4ee4\u4e5f\u8bd5\u56fe\u6740\u6b7b\u6240\u7559\u4e0b\u7684\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p>\u4f46\u8fd9\u4e2a\u547d\u4ee4\u4e5f\u4e0d\u662f\u603b\u80fd\u6210\u529f--\u6216\u8bb8\u4ecd\u7136\u9700\u8981\u5148\u624b\u5de5\u6740\u6b7b\u5b50\u8fdb\u7a0b\uff0c\u7136\u540e\u518d\u6740\u6b7b\u7236\u8fdb\u7a0b\u3002<\/p>\n<p>*TERM\u4fe1\u53f7<\/p>\n<p>\u7ed9\u7236\u8fdb\u7a0b\u53d1\u9001\u4e00\u4e2aTERM\u4fe1\u53f7\uff0c\u8bd5\u56fe\u6740\u6b7b\u5b83\u548c\u5b83\u7684\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p># kill -TERM PPID<\/p>\n<p>*killall\u547d\u4ee4<\/p>\n<p>killall\u547d\u4ee4\u6740\u6b7b\u540c\u4e00\u8fdb\u7a0b\u7ec4\u5185\u7684\u6240\u6709\u8fdb\u7a0b\u3002\u5176\u5141\u8bb8\u6307\u5b9a\u8981\u7ec8\u6b62\u7684\u8fdb\u7a0b\u7684\u540d\u79f0\uff0c\u800c\u975ePID\u3002<\/p>\n<p># killall httpd<\/p>\n<p>*\u505c\u6b62\u548c\u91cd\u542f\u8fdb\u7a0b\uff0c\u5982\u4e0b\uff1a<\/p>\n<p># kill -HUP PID<\/p>\n<p>\u8be5\u547d\u4ee4\u8ba9Linux\u6e29\u67d4\u7684\u6267\u884c\u8fdb\u7a0b\u5173\u95ed\uff0c\u7136\u540e\u7acb\u5373\u91cd\u542f\u3002<\/p>\n<p>\u5728\u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5f88\u65b9\u4fbf\uff0c\u5728\u5bf9\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u540e\u9700\u8981\u91cd\u542f\u65f6\u53ef\u4ee5\u6267\u884c\u6b64\u547d\u4ee4(\u4f8b\u5982\u91cd\u542fnginx\u7ecf\u5e38\u7528\u5230\u8fd9\u4e2a\u547d\u4ee4)\u3002<\/p>\n<p>*\u5fc5\u6740\u6280 kill -9 PID<\/p>\n<p>\u5f53\u4f7f\u7528\u6b64\u547d\u4ee4\u65f6\uff0c\u4e00\u5b9a\u8981\u901a\u8fc7ps -ef\u786e\u8ba4\u6ca1\u6709\u5269\u4e0b\u4efb\u4f55\u50f5\u5c38\u8fdb\u7a0b\u3002\u53ea\u80fd\u901a\u8fc7\u7ec8\u6b62\u7236\u8fdb\u7a0b\u6765\u6d88\u9664\u50f5\u5c38\u8fdb\u7a0b\u3002\u5982\u679c\u50f5\u5c38\u8fdb\u7a0b\u88abinit\u6536\u517b\uff0c\u95ee\u9898\u5c31\u6bd4\u8f83\u4e25\u91cd\u4e86\u3002\u6740\u6b7binit\u8fdb\u7a0b\u610f\u5473\u7740\u5173\u95ed\u7cfb\u7edf\u3002<\/p>\n<p>\u5982\u679c\u7cfb\u7edf\u4e2d\u6709\u50f5\u5c38\u8fdb\u7a0b\uff0c\u5e76\u4e14\u5176\u7236\u8fdb\u7a0b\u662finit\uff0c\u800c\u4e14\u50f5\u5c38\u8fdb\u7a0b\u5360\u7528\u4e86\u5927\u91cf\u7684\u7cfb\u7edf\u8d44\u6e90\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u5728\u67d0\u4e2a\u65f6\u5019\u91cd\u542f\u673a\u5668\u4ee5\u6e05\u9664\u8fdb\u7a0b\u8868\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\uff0c\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u6240\u8c13\u7684\u201c\u50f5\u5c38\u8fdb\u7a0b\u201d\uff0c\u5e94\u786e\u4fdd\u5728\u6740\u6b7b\u7236\u8fdb\u7a0b\u4e4b\u524d\uff0c\u5148\u6740\u6b7b\u5176\u6240\u6709\u7684\u5b50\u8fdb\u7a0b\u3002 centos ps -e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[322,353,386,246,387],"class_list":["post-836","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=836"}],"version-history":[{"count":0,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/836\/revisions"}],"wp:attachment":[{"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}