CPULimit, yana iyakance amfani da tsari zaiyi amfani da CPU

game da CPULimit

A cikin labarin na gaba zamuyi la'akari da CPULimit. Wannan kayan aikin layin umarni ne ƙayyade amfani da CPU ta hanyar aiwatarwa (wanda aka bayyana a kashi, ba lokacin CPU ba). Wannan zai zama da amfani don sarrafa ayyukan yawa, lokacin da ba mu son tsari don cinye yawancin abubuwan CPU.

Tare da amfani da wannan kayan aikin ba za mu canza ƙima ko wasu saitunan fifiko ba, amma ainihin amfani da CPU. Bugu da kari, yana iya daidaitawa zuwa nauyin gaba daya na tsarin, a hanzari da sauri. Ana sarrafa ikon adadin CPU da aka yi amfani da shi ta hanyar aikawa sigina NA GABA y SIGABAN POSIX zuwa matakai. Duk matakan yara da zaren abin da aka ƙayyade zai raba kashi CPU ɗaya.

Shigar da CPULimit

CPULimit shine Ana samun shi a cikin mafi yawan rumbun ajiye tsoffin kayan aikin Unix. Zamu iya girka ta ta amfani da tsoffin manajan kunshin a cikin rarraba Gnu / Linux. Misali a hannun, zamu ga yadda ake girka shi a kan Debian, Ubuntu da Linux Mint. Dole ne kawai mu buɗe tashar (Ctrl + Alt + T) kuma rubuta umarnin mai zuwa a ciki:

sudo apt-get install cpulimit

Duk wanda yake so zai iya tuntubar sauran nau'ikan kayan aiki a cikin aikin shafin GitHub.

Amfani da CPULimit

Da zarar an shigar da kayan aikin, lokaci yayi da za a ga yadda yake aiki. Don yin wannan, za mu gudanar da shirin da ke cin yawancin albarkatun CPU. Dole ne a gudana umarnin masu zuwa azaman tushen mai amfani.

Irƙirar rubutun da ke cinye albarkatun CPU

Da farko za mu je ƙirƙiri fayil da ake kira derrochecpu.sh. Zan yi amfani da Editan Vim, amma cewa kowane ɗayan yana amfani da wanda yake so. Daga m (Ctrl + Alt + T) dole ne mu rubuta:

vim derrochecpu.sh

Da zarar mun buɗe, za mu danna 'madanninEsc' sai me 'i'. Yanzu zamu kara layuka masu zuwa:

rubutun vim splurgecpu

#!/bin/bash
while :; do :; done;

Da wannan an gama, lokaci yayi da adanawa da fita. Don yin wannan zamu danna 'maɓallinEsc'kuma za mu rubuta : wq don ajiyewa da rufe fayil ɗin. Wannan ɗan gajeren rubutun zai sake maimaita cinye iyakar CPU amfani. Sabili da haka, ana ba da shawarar gwada shi a cikin na'ura ta kama-da-wane.

Yanzu zamu sanya wannan file aiwatarwa. Don yin wannan, daga wannan tashar (Ctrl + Alt T) za mu aiwatar:

chmod +x derrochecpu.sh

Unchaddamar da rubutun

Yanzu za mu ƙaddamar da tsari a bango. Za mu yi haka ta amfani da umarnin:

./derrochecpu.sh &

PID rubutun splurgeCPU

Zamu kiyaye PID din aikin. A wannan yanayin, 6472 shine PID na aikin da aka ƙaddamar.

Duba yawan CPU da yake cinyewa

Muna iya ganin adadin CPU wanda aikin da muka ƙaddamar yanzu yana cinyewa, ta amfani da umarni «saman» a cikin wannan tashar:

saman rubutun splurgeCPU

top

Kamar yadda ake iya gani a cikin sikirin da ke sama, aikin wastecpu.sh yana cinye fiye da 96% na amfani da CPU. Tunda yana cin amfani da CPU mai yawa, yana da wahala aiwatar da wasu ayyuka. Bayan 'yan mintoci, tsarin zai iya fadi ko daskarewa. Wannan shine inda CPULimt ya zo don taimakonmu.

Iyakance amfani da CPU ta PID

Yanzu, bari mu iyakance amfanin CPU na wannan aikin ta amfani da kayan aikin CPULimit. Zamu tafi iyakance amfani da CPU zuwa 35% ta hanyar PID ɗinta (kusan). Don yin haka, gudu:

cpulimit -l 35 -p 6472 &
  • Zaɓin "-L 35»Ya ƙayyade aikin zuwa kusan 35%.
  • «-p 6472»Shin PID ne na derrochecpu.sh da muka gani a baya.

Duba sakamakon CPULimit

Da zarar an ƙaddamar da umarnin da ya gabata, bari mu sake nazarin aikin CPU. Saboda wannan zamu sake amfani da babban umarni:

saman rubutu CPULimit squandering

top

Kamar yadda kake gani a hoton da ke sama, amfanin CPU na wastefulcpu.sh ya ragu zuwa 35,6%, wanda yake kusa da 35%. Yanzu ya za mu iya samun ƙarin albarkatun CPU don gudanar da wasu matakai.

Iyakance amfani da CPU ta sunan fayil

Mun ga yadda za a iyakance aiki ta amfani da PID. Kazalika za mu iya aiwatar da umarnin CPULimit wanda ke tantance sunan fayil ɗin shirin aiwatarwa.

Misali, misali guda daya da ke sama zai zama:

cpulimit -l 30 ./derrochecpu.sh &

CPULimit na iya zama mai amfani yayin aiwatar da tsari wanda ke cin amfani da CPU da yawa. Lokaci na gaba da zamu lura cewa wani shiri yana cin CPU mai yawa, kawai zamu sami PID na aikin ta amfani da umarnin «top«. Lokacin da kake dashi, kawai dole ne ka iyakance amfani da CPU ɗinka zuwa ƙaramar ƙima ta amfani da umarnin CPULimit kamar yadda aka bayyana a wannan labarin.

Cire uninstall na CPULimit

Cire wannan kayan aikin daga tsarinmu yana da sauki kamar buɗe tashar (Ctrl + Alt + T) da bugawa a ciki:

sudo apt remove cpulimit

Abin da wannan labarin ya bayyana misali ne kawai. Babu shakka, babu wani mai hankalin da zai gabatar da rubutu kamar wanda aka bayyana anan akan kwamfutarsu.


Bar tsokaci

Your email address ba za a buga. Bukata filayen suna alama da *

*

*

  1. Wanda ke da alhakin bayanan: Miguel Ángel Gatón
  2. Manufar bayanan: Sarrafa SPAM, sarrafa sharhi.
  3. Halacci: Yarda da yarda
  4. Sadarwar bayanan: Ba za a sanar da wasu bayanan ga wasu kamfanoni ba sai ta hanyar wajibcin doka.
  5. Ajiye bayanai: Bayanin yanar gizo wanda Occentus Networks (EU) suka dauki nauyi
  6. Hakkoki: A kowane lokaci zaka iyakance, dawo da share bayanan ka.

      javp m

    Sannu
    Ya zama cikakke ga tsohuwar PC ɗin da nake da ita tare da amd64 x2 wanda yake da alama yana da matsala mai sanyaya kuma idan wani tsari ya cpu cpu da yawa na severalan mintoci da yawa, zai dumama zuwa 100º C kuma ya rufe.
    Don haka, lokacin da na ga cewa wani tsari (galibi wasu shafukan yanar gizo ko shirye-shiryen bidiyo) yana sa ni ɗaga zafin jikin na cpu, zan yi amfani da cpulimit don cire "ƙarfi" daga wannan aikin.
    Gracias