Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Automatic nice values?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
correctclick
n00b
n00b


Joined: 18 Jul 2002
Posts: 71

PostPosted: Sun Dec 08, 2002 9:52 pm    Post subject: Automatic nice values? Reply with quote

Hi. Frequently, I'm compiling something while I use openoffice and my mouse begins to jump, keypresses come in spurts, etc. I found that by nice'ing openoffice (soffice-bin actually) to 20, everything gets much more responsive and there really is no difference compared to when I'm not compiling anything. My question is, is there a way for me to tell linux to always run a certain program with a certain nice value? This would save me from having to renice all the time.

I suppose a script could do it by looking for the pid in ps -A and using that to renice, but this seems like the sort of thing linux would be able to do by itself and I'd rather not take the time if there's a better way.

Any help would be appreciated, thanks.
Back to top
View user's profile Send private message
simulacrum
Tux's lil' helper
Tux's lil' helper


Joined: 30 Nov 2002
Posts: 128
Location: St Paul, MN

PostPosted: Mon Dec 09, 2002 4:30 am    Post subject: Reply with quote

I've thought about this one myself. Although I haven't done it yet, I've considered aliasing emerge to "nice -n20 emerge" in my .bashrc for root. Seems a bit clunky but would work. Anyone with a better idea?
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Mon Dec 09, 2002 6:27 am    Post subject: Reply with quote

simulacrum wrote:
I've thought about this one myself. Although I haven't done it yet, I've considered aliasing emerge to "nice -n20 emerge" in my .bashrc for root. Seems a bit clunky but would work. Anyone with a better idea?


I tried what u've said ( nice -n20 emerge ) and I got the help of emerge ;-)
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
simulacrum
Tux's lil' helper
Tux's lil' helper


Joined: 30 Nov 2002
Posts: 128
Location: St Paul, MN

PostPosted: Mon Dec 09, 2002 6:36 am    Post subject: Reply with quote

I'm saying to alias emerge to "nice -n20 emerge" so that when you emerge a package, it's nice'd down to +20.
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Mon Dec 09, 2002 6:38 am    Post subject: Reply with quote

simulacrum wrote:
I'm saying to alias emerge to "nice -n20 emerge" so that when you emerge a package, it's nice'd down to +20.


Oh, ALIAS :-) now I got it , thanks.
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
zhenlin
Veteran
Veteran


Joined: 09 Nov 2002
Posts: 1361

PostPosted: Mon Dec 09, 2002 7:00 am    Post subject: Reply with quote

I thought nice -20 is most important, and nice 20 is background task?
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Mon Dec 09, 2002 7:02 am    Post subject: Reply with quote

zhenlin wrote:
I thought nice -20 is most important, and nice 20 is background task?


Man page says:
Code:

NICE(1)                   User Commands                   NICE(1)



NAME
       nice - run a program with modified scheduling priority

SYNOPSIS
       nice [OPTION] [COMMAND [ARG]...]

DESCRIPTION
       Run  COMMAND with an adjusted scheduling priority.  With no COMMAND, print the current scheduling priority.  ADJUST is 10
       by default.  Range goes from -20 (highest priority) to 19 (lowest).

       -n, --adjustment=ADJUST
              increment priority by ADJUST first

_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
aardvark
Guru
Guru


Joined: 30 Jun 2002
Posts: 576

PostPosted: Mon Dec 09, 2002 10:33 am    Post subject: Reply with quote

zhenlin wrote:
I thought nice -20 is most important, and nice 20 is background task?


the higher the niceness, the nicer it is for you when you wanna do other things !
Back to top
View user's profile Send private message
correctclick
n00b
n00b


Joined: 18 Jul 2002
Posts: 71

PostPosted: Mon Dec 09, 2002 12:14 pm    Post subject: Reply with quote

Thanks everyone for your help, I may do that. Just one other question:

Will always giving emerge a low priority slow things down when I'm not using the computer? Obviously, when I'm not using it, I'd like it to go as fast as possible.

Thanks everyone for you help.
Back to top
View user's profile Send private message
aardvark
Guru
Guru


Joined: 30 Jun 2002
Posts: 576

PostPosted: Mon Dec 09, 2002 12:46 pm    Post subject: Reply with quote

correctclick wrote:
Thanks everyone for your help, I may do that. Just one other question:

Will always giving emerge a low priority slow things down when I'm not using the computer? Obviously, when I'm not using it, I'd like it to go as fast as possible.

Thanks everyone for you help.


I can only speak from my own experience:
When I emerge with nice -20 and I don't do anything else, top tells me that emerge (gcc) is taking up all the CPU power. When I need some power for something else It'll get the higher priority.
Basically this is what you want right?
Back to top
View user's profile Send private message
correctclick
n00b
n00b


Joined: 18 Jul 2002
Posts: 71

PostPosted: Mon Dec 09, 2002 8:25 pm    Post subject: Reply with quote

Yup, this is what I want. I was going to add a line like this to root's .bashrc

alias emerge='nice -n 19 emerge'

But I was surprised to find that there is no .bashrc! I copied one over from a redhat machine (which is what I used before gentoo), but my gentoo machine doesn't seem to be using it.

Interestingly, my user account, 'tim', does have a .bashrc, but root doesn't.

How can I tell bash to use the .bashrc I just copied to root's home upon each login?

Thanks.
Back to top
View user's profile Send private message
Zr40
Tux's lil' helper
Tux's lil' helper


Joined: 19 Sep 2002
Posts: 76

PostPosted: Mon Dec 09, 2002 10:29 pm    Post subject: Reply with quote

Try using .bash_profile instead of .bashrc, or put 'source .bashrc' in .bash_profile.
Back to top
View user's profile Send private message
correctclick
n00b
n00b


Joined: 18 Jul 2002
Posts: 71

PostPosted: Mon Dec 09, 2002 10:46 pm    Post subject: Reply with quote

Excellent, that works. Thanks.
Back to top
View user's profile Send private message
Pigeon
Guru
Guru


Joined: 21 Jun 2002
Posts: 307

PostPosted: Tue Dec 10, 2002 12:26 am    Post subject: Reply with quote

.bashrc is only used in terminal shells, and .bash_profile is only used in login shells. Login shells automatically source /etc/profile, but terminal shells do not. Kinda funky.
Back to top
View user's profile Send private message
correctclick
n00b
n00b


Joined: 18 Jul 2002
Posts: 71

PostPosted: Tue Dec 10, 2002 1:58 am    Post subject: Reply with quote

Excuse me if I'm ignorant, but why is it a login shell when I'm root and a terminal shell when I'm a user? What's the difference?

Thanks.
Back to top
View user's profile Send private message
simulacrum
Tux's lil' helper
Tux's lil' helper


Joined: 30 Nov 2002
Posts: 128
Location: St Paul, MN

PostPosted: Tue Dec 10, 2002 3:26 am    Post subject: Reply with quote

I've maintained a .bashrc for a while over various distros and installs, so mine is a bit developed by now. I also maintain a simple .profile that ensures .bashrc is executed:

if test -f ~/.bashrc; then
. ~/.bashrc
fi
Back to top
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 253
Location: Chantilly, VA

PostPosted: Wed Dec 11, 2002 8:51 am    Post subject: Reply with quote

or you could just use the gentoo supplied .bashrc and .bash_profile files


Code:
cp /etc/skel/.bash* ~


it gives you nice coloured terminal output and everything :)

proxy
Back to top
View user's profile Send private message
lanius
Retired Dev
Retired Dev


Joined: 08 Dec 2002
Posts: 160

PostPosted: Wed Dec 11, 2002 8:29 pm    Post subject: Reply with quote

Is there no better possibility to run X or KDE or any WM on a higher default priority, this solution seems a bit clunky :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum