nice
run a program with modified scheduling priority
Synopsis
nice
[OPTION] [COMMAND [ARG]...]
add an example, a script, a trick and tips
examples
source
nice rsync -rvh --size-only -progress $@
source
nice rsync --dry-run -rivh $@
source
Does the Linux 'nice' command work on any shell script?
Nice applies to the process that is started when running the
command and any child processes. So the answer to your question
is yes, it does work on any commands/scripts, even if they are
put into the background.
source
How do I elevate the priority of a process without giving that process superuser rights?
One possibility is this (which I just thought of after asking):
sudo nice -10 sudo -u user command
But it seems like there should be a more elegant method.
source
Remember the nice value in Linux
I don't really think you can. I have a shortcut / bash script
that renice
's itself and then launches the
executable associated with it. I generally don't have too many
processes that I have to renice (just my minecraft server), so I
haven't found it to be too big of an issue.
#!/bin/sh
renice 4 -p $$
mono McMyAdmin.exe
and then I just run the script instead of the executable I
usually would.
source
Why I can decrease the process's priority by using nice() function with a typical user permission(except ROOT) in linux?
#include<stdio.h>
#include<unistd.h>
#include<sys/resource.h>
void main()
{
int n=10;
(void)setpriority(PRIO_PROCESS, 0, n);
sleep(60);
while(1)
printf("Test");
}
After setting the process priority to required level, delay by 1
mins so that we can check altered priority in top/ps command.
Check this link, http://linux.die.net/man/2/setpriority
source
can I `dtach` or `renice` graphical programs like `evince`?
dtach
does not influence OS resources in the sense
that it reduces RAM or CPU cycles, dtach
detaches a
process from it's parent process. renice
on the
other hand increases / decreases the priority of the process for
the schedular; the process will gain more cpu-cycles .
So: yes, you can use dtach
to detach
evince
from your xterm
(I doubt that
you open evince via xterm
anyway). This would only
ensure that closing xterm
won't close
evince
. Yes, you can renice
a lower
priority to evince
and then the scheduler will call
evince
less often. Memory wise there won't be any
change at all. To reduce work load you might minimize
evince
so it is not visible and thus nothing
new
will be rendered and no checks against
overlapping due to other programms will take place.
But, and I mean that in all seriousness: Stop fiddling around
with your system in such micromanagement style and just buy more
RAM. As long as you don't open 1000s of evince
to be
read later (which is a usage pattern I would change in the first
place) the OS will behave not really differently when you
microtune
the OS. If you don't want to read the
.pdfs now: save them to disk. Problem solved.
source
Extra low priority processes in linux?
You could make use of cgroups for that one really low priority
process. You can create a cgroup just for that one process (call
it lowprio
or w/e) and use the
cpu.shares
parameter to only allow it a certain
share of CPU time. You can read more about this approach in,
e.g., RHEL's Resource Management Guide.
description
Run COMMAND
with an adjusted niceness, which affects process scheduling.
With no COMMAND, print the current niceness. Niceness values
range from -20 (most favorable to the process)
to 19 (least favorable to the process).
-n, --adjustment=N
add integer N to the niceness
(default 10)
--help
display this help and exit
--version
output version information and
exit
NOTE: your
shell may have its own version of nice, which usually
supersedes the version described here. Please refer to your
shell’s documentation for details about the options it
supports.
copyright
Copyright © 2012 Free Software Foundation, Inc. License GPLv3+:
GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute
it. There is NO WARRANTY, to the extent permitted by law.
reporting bugs
Report nice bugs to bug-coreutils[:at:]gnu[:dot:]org
GNU coreutils home page:
<http://www.gnu.org/software/coreutils/>
General help using GNU software:
<http://www.gnu.org/gethelp/>
Report nice translation bugs to
<http://translationproject.org/team/>
see also
nice
The full
documentation for nice is maintained as a Texinfo
manual. If the info and nice programs are
properly installed at your site, the command
info
coreutils 'nice invocation'
should give you
access to the complete manual.
author
Written by
David MacKenzie.