Linux – Imposing Minimum Niceness on a Specific User

limit

Is it possible to limit a specific user's processes to always run with a niceness of at least 15, say?

Best Answer

You can set per-user or per-group nice values using pam_limits and the /etc/security/limits.conf file.

e.g.

username    hard    priority    15

This only affects PAM services which are configured to use the pam_limits module. Depending on your distribution, this is probably already enabled for services like login, cron, atd, sshd, and others. Or you may have to enable it by adding a line like the following to, e.g., /etc/pam.d/login:

session    required   pam_limits.so

See man pam_limits and the comments in /etc/security/limits.conf for details. If you have the PAM doc package installed, there may be additional documentation at /usr/share/doc/libpam-doc/html/sag-pam_limits.html

Related Question