3

I've been trying the "nicer" way to run a gzip from a bash script on an active server, but it somehow manages to get the load average above what I would wish it would be.

Which of the following would be softer on the I/O and the CPU?

Is there another way I'm not aware of?

  1. /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 gzip -9 -q foo*

or

  1. /usr/bin/ionice -c2 -n7 /usr/bin/nice -n 19 gzip -9 -q foo*

Also, is there another commands such as ulimit that would help reducing the load on the server?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Karma Doe
  • 114
  • 12
  • I have a similar question regarding using `ionice` with `usr/bin/time`. I'm not sure if putting `ionice` before `time` will make time be "nice" but not the actual process, or if it's the opposite and having `time` before will override `ionice` (or neither and both ways work as expected). I agree with the answer below, but I'm wondering how one could formally test this. – Ricardo A. Aug 16 '18 at 14:03
  • It doesn't matter which is first, none of them does anything just they set up the process resource limits/priorities and then an `execve()`... – peterh Sep 05 '18 at 20:42

1 Answers1

4

I'm not familiar with the ionice thing, but nice just means that if another process want's to use the CPU, then the nice process will be more willing to wait a bit.

The CPU load is unaffected by this since it's just a measure of the length of the "run queue", which will be the same.

I'm guessing it'll be the same with ionice, but affecting disk load.

So, the "niceness" only affects how willing your process is to allow others to go before you in the queue, but in the end the load will be the same because the CPU/disk has to carry out the job.

ANALOGY: Think of a person behind a checkout counter as an analogy. They still has to process the queue, but the people in the queue may be nice to each other and let others pass before them to the counter. The "load" is the length of that queue.

Kusalananda
  • 14,885
  • 3
  • 41
  • 52
  • 1
    I upvoted, but "You need at least 15 privilege points" I just registered, and I´m not all that familiar with the page. To add on that it´s not my native language and it may be somehow a barrier for me. Thanks for taking some of your time to answer. Also, i got a workaround on the problem, got an additional script to scan for server load and io load and send signals to pause it and resume. Something like: if avg > "hardcoded value" `kill` -n 19 \`ps -ef | grep "foo" | grep -v grep | awk '{print $2}'\` else `kill -n 18` \`ps -ef | grep "foo" | grep -v grep | awk '{print $2}'\` – Karma Doe Jun 29 '16 at 18:22
  • @KarmaDoe You might want to look into the `pgrep` and `pkill` tools. – Kusalananda Jun 29 '16 at 18:26