Help - Search - Members - Calendar
Full Version: nice command!
The Planet Forums > Operating Systems > Red Hat Linux
mattschinkel
I like the idea of the nice command.... eg....

nice -n 19 ./command - to set low priority
nice -n -20 ./command - to set high priority


but, only root can set priority's..
If I run nice as a different user, I get the following error
"nice: cannot set priority: Permission denied"

Is there any way I can give permission to a user?


Thanks!
Azhrarn
QUOTE
Originally posted by mattschinkel
I like the idea of the nice command.... eg....

nice -n 19 ./command - to set low priority
nice -n -20 ./command - to set high priority


but, only root can set priority's..
If I run nice as a different user, I get the following error
"nice: cannot set priority: Permission denied"

Is there any way I can give permission to a user?


Thanks!


Any non-root user should be able to use renice to set any process they own to a lower priority then it is currently at. I believe only root can set a process to a higher priority. Due to the fact that increasing the priority of a process can kill the box.

The best way to do it if you are having permissions problems is probably to use the sudo command (man sudo). Create a sudoers file in /etc that gives the user you want to have access the proper permissions to nice/renice. They will however need to enter their password whenever they use the sudo command to do this.

If for some reason a user can't lower their priorities, then I'm not sure what to do. As that should certainly be possible.
mattschinkel
hmm..
I need to set a high priority to a gaming server I have running, and I don't want to run it as root...

What do you suggest?
mattschinkel
can root change the priority of a process? or is this what renice does?
Azhrarn
Yes, renice changes the priority of a running process. Any user can lower the priority of their processes, but only root can increase it.

You could set up the server and use a cronjob under root to periodically renice it I guess.
mattschinkel
hmmm...
can't get the renice command to work....

renice -n -10 10680

to set process 10679 to -10, is that right?


thanks...
mattschinkel
never mind, got it....
renice -10 10680
mattschinkel
now I would like to run a cron job... but, ever time reload the prog, it gets a different process ID...

Got any suggestions?
Is there any way I can specify the process ID i want it to run on?
Is there any way I can renice according to process name?
Azhrarn
You can probably feed renice something using grep/sed/cut to pull out the pid.
propcgamer
QUOTE (Azhrarn)
You can probably feed renice something using grep/sed/cut to pull out the pid.


sorry to bump an old thread

but would anyone know the exact command to run to pull the pid out from grep, i have some processes running as a certain user every so often that iwould like to give low priority
Chylie
QUOTE (propcgamer)
would anyone know the exact command to run to pull the pid out from grep, i have some processes running as a certain user every so often that iwould like to give low priority


Any user can set priority as long as it is greater than 0 .. only root can set negatice niceness (higher priority).
"nice -n 19 $command" should work for any user. And if you still want the PID, there may be a program named "pidof" on the system that will get the PID for you instead of going through grep.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.