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}

and

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.

Tags: 

Comments

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

Really decent post. I just unearthed your weblog and needed to say that I have truly delighted in searching your blog entries. After all I"ll be subscribing to your food and I trust you compose again soon! bike transport pune

decent post, stay aware of this intriguing work. It truly regards realize that this subject is being secured likewise on this site so cheers for setting aside time to examine this! Josh Greenly

"Boredom is a killer—which is why a cure for boredom can be a lifesaver.

The truth is, portable Bluetooth speakers have been the handheld solution to elevate the moment, whether at the beach, the middle of a party, or a lazy afternoon at home for years now—and your brand can get in on that excitement.

Right now—with C2BPromo.com, you can put you logo on a wide array of Promotional Bluetooth Speakers, in all different shapes and sizes, from waterproof to resilient wood—with models coming in at 6-7 dollars all the way up to high-end luxury designs. Multiple surfaces on almost every customized Bluetooth speaker can showcase your logo—so no matter which way it’s turned, your name is always center staged." Branded Bluetooth Speaker

kodi is an ofen source software which whichwas specially designed for by keeping entertainment in mind.It's a perfect straming appliacaction for the internet freas. It had its own community where you can solve your problems and you can get kodi here.

Add new comment