Starting sshd With a Higher Nice Value

I wanted sshd on my MythTV box to start with a lower priority than other processes. Sometimes I do large transfers to this box over scp (although usually I use nfs). I tried:

nice -n 10 /usr/sbin/sshd ${myopts} ${SSHD_OPTS}


start-stop-daemon -N 10 --stop --quiet --pidfile /var/run/${SVCNAME}.pid --signal HUP

in my /etc/init.d/sshd startup script (in Gentoo) but that didn't work. Even after restarting sshd and logging out and back in again (via ssh) there were still sshd processes running at nice level 0. I think it's because sshd likes to spawn itself at priority 0 (rather than the priority of the parent process, not sure if that is standard or not, but whatever).

The solution I came up with was to run this as a cron job:

ps -o pid -C sshd --no-heading | xargs renice 10

This renices all processes named sshd to nice level 10. This can actually be run by the normal user (if you only log in via ssh as normal user) because the processes that get nice level 0 seem to be processes created by the normal user that you log in as.



Thanks for this post. It was quite helpful. I didn't quite like the cron part of it, but I found this solution. Create ~/.ssh/rc and add this in it:
ps -o pid --no-heading | xargs renice 19 > /dev/null

I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.
new futura sale

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information.

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing
Mesothelioma Cancer

Add new comment