inside the mind of a linux admin

don’t let it go bad, go nice.

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/

This will execute the 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/

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:

# nice -n 19 ionice -c2 -n7 /path/to/shell.script

Related Posts

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

Touchpad stops working after sleep + resume (Fedora 26 on Dell XPS)

After recently upgrading my Dell XPS 13 w/Touchscreen to Fedora 26, the touchpad suddenly stopped working upon resuming from sleep mode. It was reproduced 100% of the time, and required a complete restart in order to get the touchpad working again. There have been several forum posts and bug reports regarding others experiencing these exact […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

Twitter: kireguy

Tweeter button Facebook button Myspace button