4

I would like to run a backup script in low CPU and disk I/O.

Is there any different between this:

#!/bin/bash

ulimit -e 19
ionice -c3 -p $$

and this:

#!/bin/bash

ionice -c3 -p $$
renice -n 19 -p $$
7

There is big difference between them.

  • ulimit -e only set the RLIMIT_NICE, which is a upper bound value to which the process's nice value can be set using setpriority or nice.

  • renice alters the priority of running process.

Doing strace:

$ cat test.sh
#!/bin/bash

ulimit -e 19

Then:

$ strace ./test.sh
...................................................
read(255, "#!/bin/bash\n\nulimit -e 19\n", 26) = 26
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
getrlimit(RLIMIT_NICE, {rlim_cur=0, rlim_max=0}) = 0
getrlimit(RLIMIT_NICE, {rlim_cur=0, rlim_max=0}) = 0
setrlimit(RLIMIT_NICE, {rlim_cur=19, rlim_max=19}) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(255, "", 26)                       = 0
exit_group(0)

You can see, ulimit only call setrlimit syscall to change the value of RLIMIT_NICE, nothing more.

Note

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.