Tag Info

Hot answers tagged

14

Since linux 2.6.12, that depends on the value of the RLIMIT_NICE limit (ulimit -e). Which can take values from 0 to 40. That limit is more the limit on the priority of the process (the greater that number, the higher the priority a user can set for a process). You'll notice the default value is 20 on ubuntu 10.04 and 0 in Debian jessie for instance. A ...


14

It's for what I'd call policy reasons. The idea is that normal users can't override the actions of privileged users. Let's say you're a user on some enormous shared server. You're running monstrous CPU-hogging processes to the detriment of the other users. The sysadmin renices some of your processes because he doesn't like you very much. The OS doesn't ...


10

Disk and memory scheduling are entirely different. In the absence of an IO priority scheduler, IO will be handled on a first come first served basis. If the system is IO bound, then all processes run in a more or less round robin basis until all are waiting for I/O. The nice priority of a process will have little impact on its scheduling frequency. ...


8

Yes. However, if the nice value of the parent process changes after forking the child processes, the child processes do not inherit the new nice value. You can easily observe this with the monitoring tool top. If the nice field (NI) is not shown by default, you can add it by pressing f and choosing I. This will add the NI column to the top display. * I: NI ...


8

I would start it normally and use "renice" afterwards... However I was able to make a quick hack together with "su" which works: sudo nice -n -20 su -c command_to_run user_to_run_as (If you don't have to give sudo a password - perhaps because you've already just given it - you may add an "&" to put the whole thing in the background.) Since you ...


7

The pam_limits.so module can help you there. It allows you to set certain limits on specific individual users and groups or wildcards or ranges of users and groups. The limits you can set are typically ulimit settings but also on the number of concurrent login sessions, processes, CPU time, default priority and maximum priority (renice). Check the ...


5

The proportion of the processor time a particular process receives is determined by the relative difference in niceness between it and other runnable processes. The Linux Completely Fair Scheduler (CFS) calculates a weight based on the niceness. The weight is roughly equivalent to 1024 / (1.25 ^ nice_value). As the nice value decreases the weight increases ...


4

Surely there must be a better way than this, but on most Linux-based systems: ps -o pid -C pidgin --no-headers --deselect will give you all pids on the system, apart from those for the command pidgin, so renice -n 5 $(ps -o pid -C pidgin --no-headers --deselect) will try to renice everything butpidgin, but fail for processes you don't own


4

You can write up your own script that uses ps to list all processes in the run/runnable state without a nice value greater than 0. The specific syntax you need to use will differ based on your version of ps. Something like this may work: ps -eo state,nice | awk 'BEGIN {c=0} $2<=0 && $1 ~ /R/ { c++ } END {print c-2}' It runs ps collecting the ...


3

Changing the nice value will not directly reduce system load. It can however be used to leave more resources available to the remaining processes, which I suspect is what you really want. From http://linux.101hacks.com/monitoring-performance/hack-100-nice-command-examples/ Kernel decides how much processor time is required for a process based on the ...


3

You can set the priority for a particular user in /etc/security/limits.conf file. root hard/soft priority 10 This way u can set hard or soft limit for any particular user. So all the processes which this root user will start will have 5 as the default priority vale. According to Wikipedia page: The exact mathematical effect of setting a ...


3

I believe the correct format is: @users - priority 10 username - priority 19 This is an example of the settings I am using in production (obviously with real users/groups). The nice setting is to determine the maximum nice value someone can set their process to, not their default priority.


2

Changing the nice level of a process is unlikely to affect the system load value. The system load value is the average length of the run queue, which is basically the number of processes wanting to use the CPU. If you are running a CPU-bound process (rsync isn't, but just for example), then it will always want to use CPU time whenever there is some ...


2

*emphasized text*Since all the child processes are still a part of the session id (sess in ps output) we could exploit that fact using this command: $ parent=6187 $ ps -eo sess:1=,pid:1= |sed -n "s/^$parent //p" This should return to us all the process IDs of the child processes spawned from lb load. We can also get this directly from pgrep, using the -s ...


2

JIM=x JIM=20 nice -n 10 echo $JIM does pass the JIM=20 environment variable to nice, but it's not nice nor echo that expands $JIM, that's the shell. The shell forks a process and executes: execve("/usr/bin/nice", ["nice", "-n", "10", "echo", "x"], ["JIM=20", other vars]) nice sets the niceness and then executes in the same process: execve("/bin/echo", ...


2

I wrote a small script in perl to do what you ask: http://pastie.org/3460943 It works by getting all the current X11 window IDs using the "xlsclients -l" command, in turn getting the window's PID with xprop. It then uses xprop -root to get the currently focused window, then loops through all the PIDs to change their nice value to 5 (keeping the currently ...


2

These snippet of Debian's /etc/default/rsync (Fedora probably doesn't divert too much), # run rsyncd at a nice level? # ... RSYNC_NICE='' # run rsyncd with ionice? # ... # RSYNC_IONICE='-c3' makes me think that the *NICE values only affect the rsyncd daemon. Looking at /etc/init.d/rsync, we find if [ -s $RSYNC_DEFAULTS_FILE ]; then . ...


2

As I mentioned, @glenn-jackman gave you the answer. But just to elaborate a bit more, if you wish to give higher priority to the command but do not intend to run it as root, you could use a function (and sudo): nice_cmd() { PRIORITY=$1 ; shift CMD=$1 ; shift ${CMD} $@ & cmdpid=$! sudo renice -n ${PRIORITY} -p ${cmdpid} } Then execute it as ...


2

I can confirm that that doesn't work on my system either. The docs say "kernel 2.6.11 and up", and I'm on Fedora rawhide with kernel 2.6.38-rc6. I wonder if it is scheduler-dependent, and doesn't work with the introduced-in-2.6.23 CFQ ("Completely Fair Scheduler"). Something that will work, though, is the ...


2

Using renice without sudo would be impossible. I quote from the renice(1) man page: Users other than the super-user may only alter the priority of processes they own, and can only monotonically increase their ``nice value'' (for security reasons) within the range 0 to PRIO_MAX (20), unless a nice resource limit is set (Linux 2.6.12 ...


1

Relatively new feature to the kernel, but if your platform supports it you can create a cgroup for the pid after the fact give it the PID of the process and manipulate its cpu.shares value to give it as much as or as little as it needs. more info


1

It looks like you can set a default priority for a user in limits.conf, with a line like: username soft priority 5 See man limits.conf.


1

In fact, RLIMIT_NICE allows you to bypass the basic rule that says that "a process can raise its nice value only if owned by root". Demonstration: # ulimit -e 30 # su nobody $ nice -n -10 top You will see that your top process runs with niceness -10. Now if you try nice -n -11 top, it will run with niceness 0, because -11 is not allowed by ...



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