0
Thanks

A few words of thanks would be greatly appreciated.

Launching a program in low CPU and disk I/O priority





Intro


Sometimes it happens that you want to laubnch some heavy operations in the background without slowing down other software. For example:
Copying files
Backups
Indexing (updatedb).

In this situation nice and ionice can be used.
  • nice allows you to reduce the priority of a process on the CPU
  • ionice reduces the priority of a process on disk access.


Launching a program

ionice -c3 nice -n15 myprogram


The program launched will use CPU and disk resources only when no other program is making use of it.

In a shell script


Place at the beginning of your shell script:

#!/bin/sh
ionice -c3 -p$$
renice +15 -p $$


The shell will have its priority reduced (and this will be applicable for all programs launched within this shell).

This is useful in the scripts launched in /etc/cron.

You can add these lines to your script: /etc/cron.daily/slocate

Notes


nice and renice can be used by everyone.
ionice with -c3 can be used only by root.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Published by . Latest update on by jak58.

This document, titled "Launching a program in low CPU and disk I/O priority," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments