Questions tagged [nice]

nice is a UNIX kernel call and the name of a utility employed to lower or raise a process' CPU priority.

nice is a program found on Unix and Unix-like operating systems such as Linux.

It directly maps to a kernel call of the same name. nice is used to invoke a utility or shell script with a particular priority, thus giving the process more or less CPU time than other processes. A niceness of −20 is the highest priority and 19 or 20 is the lowest priority. The default niceness for processes is inherited from its parent process, usually 0.

Source: Wikipedia

For questions about the Nice programming language, use .

101 questions
46
votes
3 answers

Python: ulimit and nice for subprocess.call / subprocess.Popen?

I need to limit the amount of time and cpu taken by external command line apps I spawn from a python process using subprocess.call , mainly because sometimes the spawned process gets stuck and pins the cpu at 99%. nice and ulimit seem like…
Parand
  • 102,950
  • 48
  • 151
  • 186
36
votes
5 answers

Controlling scheduling priority of python threads?

I've written a script that uses two thread pools of ten threads each to pull in data from an API. The thread pool implements this code on ActiveState. Each thread pool is monitoring a Redis database via PubSub for new entries. When a new entry is…
backus
  • 4,076
  • 5
  • 28
  • 30
23
votes
3 answers

is nice() used to change the thread priority or the process priority?

The man page for nice says "nice() adds inc to the nice value for the calling process. So, can we use it to change the nice value for a thread created by pthread_create? EDIT: It seems that we can set the nice value per thread. I wrote an…
pierrotlefou
  • 39,805
  • 37
  • 135
  • 175
22
votes
6 answers

sudo nohup nice <-- in what order?

So I have a script that I want to run as root, without hangup and nicely. What order should I put the commands in? sudo nohup nice foo.bash & or nohup nice sudo foo.bash & etc. I suspect it doesn't matter but would like some insight from those who…
Jonah Braun
  • 4,155
  • 7
  • 29
  • 31
20
votes
1 answer

Niceness and priority processes on Linux system

I am looking for a way to modify a process' priority through command line. I found the builtin (bash) nice and the command renice which allow to modify the niceness of the process, but not the actual priority which is calculated by the kernel. Is…
Hugo
  • 535
  • 1
  • 3
  • 13
15
votes
2 answers

Nicing a running python process?

When my longer-running programm starts, I want to lower its priority so it does not consume all resources avaiable on the machine it runs. Circumstances make it necessary that the programm limits itself. Is there a nice-like python-command I could…
AME
  • 2,499
  • 5
  • 29
  • 45
13
votes
7 answers

Is it possible to renice a subprocess?

I know about os.nice() it works perfect for parent process, but I need to do renice of my child subprocesses. I found way to do this, but it seems to be not very handy and too excessive: os.system("renice -n %d %d" % ( new_nice, suprocess.pid )…
ramusus
  • 7,789
  • 5
  • 38
  • 45
12
votes
1 answer

Can a docker container be run `nice`ly?

I have a docker image that hosts a web server and another that runs background tasks. Most of the time the web server is idle, and the background tasks should be allowed to use 100% of the CPUs, but any time the web server needs resources, it should…
rjmunro
  • 27,203
  • 20
  • 110
  • 132
11
votes
1 answer

Does renice on a parent renice the child?

I know if I nice a shell script (ie: before it runs) all processes that start from the shell script will also be niced. What if I start a shell script and the renice it, do all the child processes become reniced as well? Looked in the renice man…
hhafez
  • 38,949
  • 39
  • 113
  • 143
10
votes
2 answers

Set niceness of each process in a multiprocessing.Pool

How can I set the niceness for each process in a multiprocessing.Pool? I understand that I can increment niceness with os.nice(), but how do call it in the child process after creating the pool? If I call it in the mapped function it will be called…
jsj
  • 9,019
  • 17
  • 58
  • 103
10
votes
4 answers

Python - decrease niceness value

Using python I can easily increase the current process's niceness: >>> import os >>> import psutil >>> # Use os to increase by 3 >>> os.nice(3) 3 >>> # Use psutil to set to 10 >>> psutil.Process(os.getpid()).nice(10) >>>…
TDN169
  • 1,397
  • 2
  • 13
  • 31
9
votes
1 answer

How to give a user ionice level permission?

To change hardlimit for nice I can modify /etc/security/limits.conf user - nice -11 But how can I do same thing for ionice ionice -c 1 -p 31828 I am getting error ionice: ioprio_set failed: Operation not permitted
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
8
votes
3 answers

Difference between nice and setpriority in unix

I'm trying to implement a different flavor of the 'nice' command of unix in C. I have seen the definitions of nice() system call and setpriority() call. The nice() call only increments/decrements the priority of the process. If I want to set the…
Aswin Parthasarathy
  • 605
  • 1
  • 8
  • 17
8
votes
5 answers

Is there some way to "nice" my JavaScript execution?

I'd like to run some calculations in a browser window, but I don't want it to slow the client computer down for user interaction, especially for single core machines. Is there some way to adjust the nice level of my executing JavaScript so that it…
shino
  • 4,562
  • 5
  • 38
  • 57
8
votes
4 answers

Why are niceness values inversely related to process priority?

The niceness of a process decreases with increasing process priority. Extract from Beginning Linux Programming 4th Edition, Pg 169 : The default priority is 0. Positive priorities are used for background tasks that run when no other higher…
asheeshr
  • 4,088
  • 6
  • 31
  • 50
1
2 3 4 5 6 7