2

I'm writing a shell script to copy gigabytes of data from directory A to directory B.

The script runs just fine, but it's absolutely eating the available resources - presumably disc read/writes?

Is there some way of throttling processes to limit their resource usage for disc / processor / ram etc?

5

Linux kernel has different scheduling classes for I/O. Use ionice command to benefit from them.

For example

ionice -c 3 your_copy_script.sh

would run your script in idle class, meaning script would only get I/O time whenever no other process needs it.

If you need to modify an already running process,

ionice -c 3 -p pid_of_your_program

would do it. See man ionice for more information.

  • Don't forget to ensure the CFQ scheduler is selected. From the man page: "Linux supports io scheduling priorities and classes since 2.6.13 with the CFQ io scheduler." – Stu Thompson Apr 4 '12 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.