Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

28

A child process inherits whatever nice value is held by the parent at the time that it is forked (in your example, 5). 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 ...


24

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 ...


20

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 ...


19

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 ...


18

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 ...


18

What does a niceness of (-) indicate? Notice those also have a PRI score of -100; this indicates the process is scheduled as a realtime process. Realtime processes do not use nice scores and always have a higher priority than normal ones, but still differ with respect to one another. You can view details per process with the chrt command (e.g. chrt -p 3). ...


18

You can use /proc/$PID/task to find all threads of a given process, therefore you can use $ ls /proc/$PID/task | xargs renice $PRIO to renice all threads belonging to a given process. Same way /proc/$PID/task/$PID/children can be used to find all child processes (or /proc/$PID/task/*/children if you want all child processes of all threads of a given ...


16

nice -n 15 sh -c "command1 | command2 | command3" This sets niceness of a subshell, and the commands 1..3 inherit it.


12

nice -n 15 command1 | nice -n <num> command2 | nice -n <num> command3 nice isn't used differently from any other command.


10

Have a look at cgroups, it should provide exactly what you need - CPU reservations (and more). I'd suggest reading controlling priority of applications using cgroups. That said, put the important yet often idle processes into group with allocated 95% of CPU and your other applications into another one with allocated 5% - you'll get (almost) all of the power ...


10

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 the nice value. The -n option for ionice is a simple priority for the realtime (-c 1) and best-effort (-c 2) options, with lower values being higher priority ...


9

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 switch too. $ ...


9

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 nice ...


9

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 limits....


9

It will not reduce your load. It will only let other processes use CPU time more often if there is a possible resource contention (several processes "competing" for not enough available CPU time).


9

Nice value or CPU shares ? Please note that nowadays, nice values may not be so relevant "system-wide", because of automatic task grouping, espacially when using systemd. Please see this answer for more details. Difference between threads and processes Important question on Linux, because documentation perpetuates doubts (about threads not having their ...


8

One step further @Jordan, Here's the elegant solution against sudo nice -n -xx su <username> -c matlab hack Note: Using username=sid, matlab meta-data dir=/var/lib/matlab, nice=-10 change at your will Create matlab meta-data dir(PERPARE) sudo mkdir /var/lib/matlab Add specified user to launch matlab & right persimisson sudo useradd -d /...


8

From reading man systemd-run, it will create a service and thus a cgroup on the fly. From reading systemd.exec, the Nice= directive will apply to all executed processes, so the way that systmd handles the concepts of Nice= and CPUShares= are very similar. My understanding of the relationship is that it has to do with history. nice has existed for a listed a ...


7

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 ...


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 ................................................... ...


7

Internal niceness levels are 0-39, but increments are positive or negative. Source. So the answer is that the numbers (positive and negative) accepted by the nice command are what get you from 20, the default level, to anywhere in the 0-39 range. So why 0-39? The specific range was what worked in the designers' original implementation. The reason more ...


7

The following format should works fine: nice -n 7 waffles & e.g. nice -n 5 date & [1] 30920 Thu May 4 17:32:19 IDT 2017 Adding & at the end of the command sends it to the background


7

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 nice -n 19 ionice ... to minimize its CPU impact. But neither of these is true, they're both very simple commands (they just make a system call to change a ...


6

@Goldlilock's answer directed me to do the research in the right path. This is my research details. Scheduling Algorithms available for processes Linux supports 3 scheduling policies. SCHED_FIFO, SCHED_RR, and SCHED_OTHER. SCHED_OTHER is the default universal time-sharing scheduler policy used by most processes; SCHED_FIFO and SCHED_RR are intended for ...


6

If the process priority (nice value) is low then it will not be interrupting a higher priority process. The reason you're seeing the low priority process still consuming a significant amount of CPU when the higher priority process is running is because the higher priority process is not that busy. Probably waiting on IO. Use chrt -p -i 0 $PID to run the ...


6

It should be enough to modify your ~/.bash_profile so it reads: if [ -f /bin/ksh93 ] then renice -n 4 $$ exec -l /bin/ksh93 fi The renice -n 4 $$ will set the nice value of the current shell ($$) to four, causing subsequent commands launched by that shell to inherit the same niceness value. I have not tested in a tmux session, but it works as ...


6

nice launches a new command with a modified nice level (lower priority than it would have otherwise had, or higher priority if you have permission). You specify which command to launch by providing it as an argument to nice itself. nice actually execs that command, so nice itself doesn't terminate until the command does. renice changes the priority of an ...


6

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 process by the H letter. As previously told by @Totor, with NPTL, which is the current implementation with kernel > 2.6, all threads have the same pid, but ...


6

You may not personally be using cron, but the system uses it for essential maintenance tasks, such as rotating log files that have grown too big or too old, checking disk quotas, doing consistency checks, making sure permissions on essential files are correct, or mailing the root user differences between important configuration files that have changed since ...


5

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 ...


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