So you’ve got a process that is taking forever to complete, and is killing your server.
Make it play nice.
What is nice?
You can run a program with modified scheduling priority using nice command (19 = least favorable):
# nice -n19 /path/to/your/script.sh
This will execute the script.sh with the lowest priority, meaning the system scheduler gives less resources to it. Values range from -19 to 19, where the lower the number the higher the priority.
Just because you started a process without nice or ionice, does not mean you can’t change its’ priority to “baby it” back to normalcy.
For more information on how to do this, check out renice (man renice).
=======================================================
Disk I/O nice
ionice is what you want to use when you’ve got a process that is driving your disks insane.
How do I use ionice command?
Linux refers the scheduling class using following number system and priorities:
Scheduling class Number Possible priority
real time 1 8 priority levels are defined denoting how big a time slice a given process will receive on each scheduling window
best-effort 2 0-7, with lower number being higher priority
idle 3 Nil ( does not take a priority argument)
To display the class and priority of the running process, enter:
# ionice -p {PID}
# ionice -p 1
Sample output:
none: prio 0
Dump full web server disk / mysql backup using best effort scheduling (2) and 7 priority:
# /usr/bin/ionice -c2 -n7 /root/scripts/my/script.sh
There is no “reionice”, but the same functionality can be achieved using the ionice tool, like so (where 25374 is the PID# you want to reionice):
# ionice -p25374 -c2 -n7
Finally, you can also combine both nice and ionice together:
Tweet# nice -n 19 ionice -c2 -n7 /path/to/shell.script
Erik
Saturday, October 16, 2010
linux administration - tips, notes and projects
No Comment