{"id":3948,"date":"2020-02-08T11:39:21","date_gmt":"2020-02-08T04:39:21","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=3948"},"modified":"2020-03-03T15:57:50","modified_gmt":"2020-03-03T08:57:50","slug":"huong-dan-gioi-han-cpu-cho-cac-tien-trinh-linux-centos-ubuntu-voi-cpulimit","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/huong-dan-gioi-han-cpu-cho-cac-tien-trinh-linux-centos-ubuntu-voi-cpulimit\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn gi\u1edbi h\u1ea1n CPU cho c\u00e1c ti\u1ebfn tr\u00ecnh Linux (Centos, ubuntu &#8230;) v\u1edbi CPULimit"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/WxBpBpgGVBY\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Cpulimit \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 h\u1ea1n ch\u1ebf vi\u1ec7c s\u1eed d\u1ee5ng CPU c\u1ee7a m\u1ed9t ti\u1ebfn tr\u00ecnh theo c\u00e1ch t\u01b0\u01a1ng t\u1ef1 nh\u01b0 CPUTool, tuy nhi\u00ean, n\u00f3 cung c\u1ea5p nhi\u1ec1u t\u00f9y ch\u1ecdn s\u1eed d\u1ee5ng h\u01a1n.<\/p>\n<h3 id=\"C\u00e0i_\u0111\u1eb7t_CPULimit_tr\u00ean_linux\">C\u00e0i \u0111\u1eb7t CPULimit tr\u00ean linux<\/h3>\n<p>V\u1edbi <strong>Debian\/Ubuntu\u00a0<\/strong>b\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t v\u1edbi l\u1ec7nh sau :<\/p>\n<pre>sudo apt install cpulimit<\/pre>\n<p>V\u1edbi <strong>RHEL\/CentOS<\/strong>\u00a0and\u00a0<strong>Fedora <\/strong>b\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t v\u1edbi l\u1ec7nh sau :<\/p>\n<pre>yum install epel-release\r\nyum install cpulimit<\/pre>\n<h3 id=\"Gi\u1edbi_h\u1ea1n_process_v\u1edbi_CPULimit\">Gi\u1edbi h\u1ea1n process v\u1edbi CPULimit<\/h3>\n<p>\u0110\u1ea7u ti\u00ean ch\u00fang ta t\u00ecm hi\u1ec3u v\u1ec1 c\u00e1ch th\u1ee9c ho\u1ea1t \u0111\u1ed9ng c\u1ee7a cpulimit, tr\u01b0\u1edbc ti\u00ean ch\u00fang ta h\u00e3y th\u1eed ch\u1ea1y m\u1ed9t l\u1ec7nh <strong>dd <\/strong>\u1ed5 c\u1ee9ng .<\/p>\n<pre>dd if=\/dev\/zero of=\/dev\/null &amp;\r\n[1] 793<\/pre>\n<p>Nh\u01b0 v\u1eady ta th\u1ea5y \u0111\u01b0\u1ee3c m\u1ed9t ti\u1ebfn tr\u00ecnh v\u1edbi ID l\u00e0 <strong>1111<\/strong> \u0111\u01b0\u1ee3c t\u1ea1o ra. b\u1ea1n c\u00f3 th\u1ec3 theo d\u00f5i ti\u1ebfn tr\u00ecnh n\u00e0y qua l\u1ec7nh <strong>top -c<\/strong><\/p>\n<p><a href=\"https:\/\/www.screencast.com\/t\/LCoXfAzwiQ\" rel=\"nofollow noopener\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/content.screencast.com\/users\/JohnGrayWorld\/folders\/Snagit\/media\/9ece1c9c-d6d6-47c0-b5ce-9ae205afacca\/02.08.2020-11.20.png?source=oembed\" alt=\"02.08.2020-11.20.33\" width=\"500\" height=\"144\" title=\"\"><\/a><\/p>\n<p>\u1ede \u0111\u00e2y t\u00f4i th\u1ea5y ti\u1ebfn tr\u00ecnh n\u00e0y lu\u00f4n ch\u1ea1y v\u1edbi 100% cpu (1 core), gi\u1edd t\u00f4i th\u1eed gi\u1edbi h\u1ea1n v\u1edbi CPUlimit.<\/p>\n<pre>cpulimit --pid 1111 --limit 50<\/pre>\n<p>Hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3 ch\u1ea1y.<\/p>\n<pre>[root@sv nginx-1.16.0]# cpulimit --pid 1111 --limit 50\r\nProcess 1111 found<\/pre>\n<p>B\u1ea1n l\u01b0u \u00fd, kh\u00f4ng tho\u00e1t m\u00e0n h\u00ecnh khi s\u1eed d\u1ee5ng l\u1ec7nh n\u00e0y, b\u1ea1n c\u00f3 th\u1ec3 d\u00f9ng m\u1ed9t tab kh\u00e1c \u0111\u1ec3 ki\u1ec3m tra cpu \u0111ang gi\u1edbi h\u1ea1n:<\/p>\n<p><a href=\"https:\/\/www.screencast.com\/t\/VG3aAOJK\" rel=\"nofollow noopener\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/content.screencast.com\/users\/JohnGrayWorld\/folders\/Snagit\/media\/b3efc198-b07d-457a-abdb-a02b8d85e113\/02.08.2020-11.27.png?source=oembed\" alt=\"02.08.2020-11.27.19\" width=\"500\" height=\"81\" title=\"\"><\/a><\/p>\n<p>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cpulimit \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 h\u1ea1n ch\u1ebf vi\u1ec7c s\u1eed d\u1ee5ng CPU c\u1ee7a m\u1ed9t ti\u1ebfn tr\u00ecnh theo c\u00e1ch t\u01b0\u01a1ng t\u1ef1 nh\u01b0 CPUTool, tuy nhi\u00ean, n\u00f3 cung c\u1ea5p nhi\u1ec1u t\u00f9y ch\u1ecdn s\u1eed d\u1ee5ng h\u01a1n. C\u00e0i \u0111\u1eb7t CPULimit tr\u00ean linux V\u1edbi Debian\/Ubuntu\u00a0b\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t v\u1edbi l\u1ec7nh sau : sudo apt install cpulimit V\u1edbi RHEL\/CentOS\u00a0and\u00a0Fedora b\u1ea1n c\u00f3 [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[17],"class_list":["post-3948","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-huong-dan-ve-cloud-vps"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/3948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=3948"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/3948\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=3948"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=3948"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=3948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}