Can you stack nice and ionice?

Cameron Simpson cs at zip.com.au
Thu May 3 22:36:50 UTC 2012


On 03May2012 16:08, Richard Shaw <hobbes1069 at gmail.com> wrote:
| I have a CPU and IO intensive task I'd like to tame a bit but I'm not
| sure if this can be done in a one-liner. Since both nice and ionice
| are designed to run only a single command I'm not sure if the
| following would work:
| 
| ionice -c3 nice -n19 <process>
| 
| It looks like to me that ionice is going to run nice who's going to
| run the task.

Should work just fine. ionice _is_ running just one command:

  nice -n19 <process>

Note that "<process>" will need to be a command, and not something like
"-p pid".

| I tried examining the first example using pstree but I don't think the
| processes "stacked".

They will exec, so no parent/child stuff. ionice will set the ionice
setting then exec the next command. Likewise nice.

There are plenty of little commands with this behaviour: make a setting
change and then execute comething with the new setting: env etc. I've
got a bunch of shell scripts with similar usage patterns as well. These
"prefix" commands make a lot of simple things very easy to express in
scripts.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Like dogs and muggers, transistors can sense fear.      - Norman Yarvin


More information about the users mailing list