Skip to main content
30 votes
Accepted

Why does `nice` with a negative argument (e.g. `nice -15`) increment niceness?

The portable syntax requires -n if you want to specify an increment. When in doubt, use nice -n. In nice -15 the argument is not really a negative number. It is a dash concatenated with a positive ...
Kamil Maciorowski's user avatar
25 votes
Accepted

nice and ionice: which one should come first?

If nice caused lots of I/O, you would want to do: ionice -c 3 nice ... so that the impact of the I/O would be minimized. Conversely, if ionice performed lots of computation, you would want to do ...
Barmar's user avatar
  • 10.6k
16 votes

Using and understanding systemd scheduling-related options in a desktop context

CPUScheduling{Policy|Priority} The link tells you that CPUSchedulingPriority should only be set for fifo or rr ("real-time") tasks. You do not want to force real-time scheduling on services. ...
sourcejedi's user avatar
  • 53.5k
15 votes

Difference between nice level and systemctl CPUShares property

On Linux, a nice value applies to a task, that is a process or thread (see link for disambiguation), a "CPU shares" value applies to a task group (for example: a cgroup). The default non-...
Totor's user avatar
  • 21.1k
12 votes
Accepted

when piping command, is nice applied to all chain?

No, nice (as opposed to the ! or time shell keywords for instance¹) is a standalone command, so it could not apply to other commands that are piped to it or that it is piped to. The change of niceness ...
Stéphane Chazelas's user avatar
11 votes

nice and ionice: which one should come first?

There is no practical difference between option A and option B.
sourcejedi's user avatar
  • 53.5k
11 votes

How to renice all threads (and children) of one process on Linux?

We should not confuse the process PID and the thread id sometime written TID or in the ps command LPW. The scommand has options to display threads, and under top or htop you switch between threads and ...
marcz's user avatar
  • 211
10 votes
Accepted

What is the nicest a Unix command can be?

The full command you want is: chrt -b 0 nice -n 19 ionice -c 2 -n 7 [command] The chrt command at the beginning will switch things to the batch scheduling class, which is equivalent to adding 0.5 to ...
Austin Hemmelgarn's user avatar
9 votes

How to renice all threads (and children) of one process on Linux?

According to man renice (emphasis mine): renice alters the scheduling priority of one or more running processes. The first argument is the priority value to be used. The other arguments are ...
Marc.2377's user avatar
  • 1,202
8 votes
Accepted

How can I find location of PRI in /proc

The priority and niceness values are given by fields 18 and 19 in /proc/<pid>/stat. See man 5 proc or man 5 proc_pid_stat for details. awk '{print $18 " " $19}' /proc/1957/stat or ...
Stephen Kitt's user avatar
6 votes

Should I set nice value lower for a user process to make it faster?

Programs that are started usually have a nice-value of zero, i.e. it's not higher or lower than the nice-values of most other processes running on the system. The nice-value modifies the scheduling ...
Kusalananda's user avatar
  • 356k
5 votes
Accepted

Is there a guideline for setting nice values?

Is there a guideline for setting nice values for application developers? No, because that's not something you can control; nor should you try to. (You will just annoy the system administrators who ...
Wildcard's user avatar
  • 37.5k
5 votes
Accepted

Process Priority value is different in procfs

Uh, apparently the pri field is exactly 39 minus the value that is visible in /proc/$pid/stat (so 39 - 20 = 19). It's also commented as 'not legal as UNIX "PRI"', since Unix98 only specifies that a ...
ilkkachu's user avatar
  • 148k
4 votes
Accepted

Should I set nice value lower for a user process to make it faster?

Short answer You can't (as a normal user), because it is a bad idea. Long answer Most of the time it will make no difference (if it is the only process running, or if the total number of threads ...
ctrl-alt-delor's user avatar
4 votes

How to renice all threads (and children) of one process on Linux?

I'd like to recommend using the -g (process groups) argument instead of the -p (process id's) while using renice. It does the same thing without the bash-foo. i.e. (sudo) renice -n <NEW_PRIORITY&...
user12042's user avatar
  • 141
4 votes

How can I find location of PRI in /proc

While the raw values come from /proc/<pid>/stat, ps may change the values that you see. For nice, if you use a different sort of scheduler, then the output may be '-' because the nice value is ...
Craig Small's user avatar
  • 1,063
3 votes

How to set process to the lowest possible priority on Linux?

You can check the results (except for the I/O scheduling) of whatever you do with: /bin/ps -eo pid,rtprio,class,pri,ni,args As a regular user you get access to Systemd limits (or at least some of ...
Hauke Laging's user avatar
  • 94.6k
3 votes

Set highest CPU and IO priority for a systemd service

You need to set 3 things: CPU scheduling and its priority, IO scheduler and niceness. To make your service use the highest values for all of these: [Unit] ... [Service] CPUSchedulingPolicy=rr ...
VasyaNovikov's user avatar
  • 1,559
3 votes
Accepted

In Linux how do I wrap an executable in a script so arguments and output work as the original executable expects?

The puzzle piece I was missing was that I wasn't using the full path of the target executable. This is the solution. Thanks to all the commenters that were helping! #!/bin/bash nice -n 10 /home/...
Neros's user avatar
  • 179
2 votes

How to renice a group of processes?

This is not scriptable, but in htop, you can renice a full tree of processes at once: If necessary, press F5 to enter tree mode. Press Z (shift+z) to pause updates, then highlight the base process ...
nyanpasu64's user avatar
2 votes

GNU Parallel Limit Memory Usage

Things have changed since 2014. Git version e81a0eba now has --memsuspend --memsuspend size (alpha testing) Suspend jobs when there is less than 2 * size memory free. The size can be postfixed with K,...
Ole Tange's user avatar
  • 37.5k
2 votes

Run Linux process at very very low priority?

For future-comers, here is a full example of nice with stress. The test machine has 2 CPUs $ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian ...
Shadi's user avatar
  • 139
2 votes
Accepted

Linux - Process get as much resources as possible but give out resources when other processes coming in

There are few ways to achieve what you want. You can use nice, cgroups, cpulimit to limit the cpu usage. You are in right direction by giving nice -19 right command to give niceness is nice -n 19 ...
AsenM's user avatar
  • 598
2 votes

Does it make sense to combine chrt and nice?

Niceness doesn't influence the SCHED_IDLE scheduling policy itself. But the CPU time consumed by "nice processes" is accounted for and subsequently displayed in various monitoring tools ...
WGH's user avatar
  • 229
2 votes
Accepted

Using cgroups and nice with respect to the same process - does the order matter? What is the correct syntax?

Both commands are preparation commands exec-ing the following command while keeping the property they changed. So the order here won't matter as long as the changed properties don't have any side ...
A.B's user avatar
  • 39.5k
2 votes
Accepted

macOS 10.13.4 - `renice` seems to have no effect

Running some rudimentary tests I’m seeing this too on 10.13.4. I wrote a small C program called looper which did some basic maths in an infinite loop: #include <stdio.h> int main(){ ...
forquare's user avatar
  • 3,576
1 vote
Accepted

Process state characterization in output of ps command

As Kusalananda said, any value less than zero is not nice to other users, and any value greater than zero is nice to other users. I couldn’t find documentation which is explicit about this, but you ...
Stephen Kitt's user avatar
1 vote
Accepted

Why can't I `nice` a command group?

The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument. There is only on case where ...
schily's user avatar
  • 19.7k
1 vote
Accepted

niceness of a background process

The user running this script is starting it in the background from an interactive ksh shell session. The ksh shell has a shell option called bgnice, which in ksh93 is on by default, which causes the ...
Kusalananda's user avatar
  • 356k

Only top scored, non community-wiki answers of a minimum length are eligible