HowFlow


HowFlow — We all know it: there are daily or weekly cron jobs to index the man pages or the whole filesystem and Gentoo users do an 'emerge --sync' almost daily, but those I/O-heavy tasks are slowing down the Linux computer, especially with the current I/O schedulers.

Share it!   Posted by aroedl aroedl 5 months ago

Solution

It doesn’t help to just renice the process, because those processes are not very CPU-heavy and thus won’t be affected if you set them to a nice level of 19. What we need is a tool to set the I/O-niceness: ionice.

Just prepend the command you wish to run with ionice -c3. ionice is part of the util-linux package, that is installed by default on all newer Linux distributions.

Now you can go through your cron entries and prepend them with ionice -c3. This is the cron script for slocate (on Gentoo):


#! /bin/sh

if [ -x /usr/bin/updatedb ]
then
        if [ -f /etc/updatedb.conf ]
        then
                ionice -c3 /usr/bin/updatedb
        else
                ionice -c3 /usr/bin/updatedb -f proc
        fi
fi

Gentoo users could and should run emerge—sync or eix-sync like that:


ionice -c3 emerge --sync
ionice -c3 eix-sync

I’d even go so far and run all emerge commands with ionice, because it usually doesn’t really matter when exactly an emerge is finished. As a Gentoo expert, you know that you can set the CPU niceness with PORTAGE_NICENESS=”19” in your /etc/make.conf anyways.

From now on, you have another tool in your mental toolbox. Think twice if a simple nice is sufficient, because a lot of tasks are rather I/O than CPU heavy.



Please log in or sign up and vote for this trick if it was helpful for you.
Don't forget to subscribe to our RSS Feed RSS/Atom feed to get the latest tricks.