I know that niceness values are inherited from the niceness value of the parent process, but can I globally change the default niceness value for a particular user (myself).
In this case I have a small convenience server in mind, which is exclusively accessed via ssh. So, I think I could change my default shell from /bin/bash to /etc/bash5 while /etc/bash5 is this script:
#!/bin/sh
nice -n 5 /bin/bash
#file privileges: root:root 755
This strikes me as a terrible hack and error prone. There must be a better way.
I'm mostly interested in general solutions, that would also apply to a desktop/laptop system.
Edit: I tried the suggested limits.conf change, but it doesn't work as expected:
root@server# addgroup nice
root@server# adduser myself nice
root@server# echo '@nice soft nice 5' >> /etc/security/limits.conf
Then, from my client machine, I say
myself@client$ ssh server
myself@server$ sleep 1h &
myself@server$ htop
Now, the sleep process has an initial niceness value of 0, but if I change the value with F8 to 19 and then try to reduce it again with F7 it stops at 5.
Edit2: Solution
Instead of using the nice item in limits.conf, you actually have to use priority although it is counter-intuitive.
@nice soft priority 5




renice -n 5in your~/.profile? – jw013 Aug 1 '12 at 18:00bash5approach, I give you this. But it still breaks if I sayssh myserver -- somecommanddoesn't it? – bitmask Aug 1 '12 at 18:02limits.conf. What's your output forps -o pid,nice,cmd? – donothingsuccessfully Aug 3 '12 at 8:40nice. – mattdm Aug 3 '12 at 19:16