Why is DU causing high CPU usage

command-line-interfacecpu-usagedu

On CentOS 6.5, du -sk /home and sh -c (du -sk \/home) 2>/dev/null run because a scheduled disk usage for /home, but du is causing 100% CPU usage. Plus, before it's even finished, another du gets run and it piles up, bringing the system down to its knees.

I've since disabled the automated checks, but I can't run du -sk /home manually either. du runs fine (fast) on other directories (though /home is the largest – 4912620 – it shouldn't take as long as it does)

I would like to find out why is DU causing high CPU usage on /home


UPDATE 1: A full restart (host+guest) solved the problem.

UPDATE 2: Problem came back. While du is running, CPU usage is split nearly half and half between (us) and (sy). (wa) never creeps over 1%. Also, IOWAIT shows only disk writes?

Best Answer

I can't tell you why exactly, but here's what I'd do to narrow down what is going on:

cd /home
for i in * ; do echo "Starting in ${i}..." ; du -s ${i} ; done

This will run "du -s" for each command inside the /home directory, and show you what it is about to do. This is also assuming you are using sh or bash as your shell.

When you find which directory is causing the problem, move in one directory more, and see what happens there. Also remember this will not check for hidden ("dot") directories at the level you start the for loop from. You may need to check those as well, or modify the glob expression to include them.

Related Topic