باستخدام اداة اسمها cpulimits يمكن وضع حد لتنفيذ عملية معينة .
يجب تنفيذ الخطوات القادمة كمستخدم جذر root
sudo su |
اذا كان جهازك يحتوي علي معالج واحد فقط فيمكن استخدام الحد مابين 0٪ الي 100% مثلا لو قمنا بوضع حد اقصي للمعالج لعملية معينة 50% فان العملية لايمكن ان تستخدم اكثر من 500 ms من وقت المعالج في كل ثانية ،
و لكن في حالة الجهاز يحتوي علي 4 معالجات فانه يمكن وضع الحد مابين 0% الي 400% و هكذا.
تثبيت Cpulimits
توجد حزمة ثنائية خاصة بالاوبونتو في المخازن فنقوم بعملية التثبيت مباشرة
aptitude install cpulimit |
استخدام Cpulimits
اولا نقوم بنظرة علي man cpulimit
man cpulimit |
NAME
cpulimit -- limits the CPU usage of a process
SYNOPSIS
cpulimit TARGET [OPTIONS...]
DESCRIPTION
TARGET must be exactly one of these:
-p, --pid=N
pid of the process
-e, --exe=FILE
name of the executable program file
-P, --path=PATH
absolute path name of the executable program file
OPTIONS
-l, --limit=N
percentage of CPU allowed from 0 to 100 (mandatory)
-v, --verbose
show control statistics
-z, --lazy
exit if there is no suitable target process, or if it dies
-h, --help
display this help and exit
EXAMPLES
Assuming you have started "foo --bar" and you find out with top(1) or ps(1) that this process uses all your CPU
time you can either
# cpulimit -e foo -l 50
limits the CPU usage of the process by acting on the executable program file (note: the argument "--bar" is
omitted)
# cpulimit -p 1234 -l 50
limits the CPU usage of the process by acting on its PID, as shown by ps(1)
# cpulimit -P /usr/bin/foo -l 50
same as -e but uses the absolute path name
AUTHOR
This manpage was written for the Debian project by gregor herrmann but may be used
by others. |
كمثال لنفترض بانن نقوم بعملية حد من استخدام المعالج ل apache2 لي يستخدم فقط 30%
cpulimit -e apache2 -l 30 |
حيث -e هي اسم العملية او البرنامج و كما يمكن استخدم رقم العملية Process ID باستخدام -p
ps aux |
او
ps aux | grep apache2 |
لنفترض انه process id ل apache2 هو 4000
cpulimit -p 4000 -l 30 |
موقع البرنامج :
http://cpulimit.sourceforge.net/












اكتب تعليقا