Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2958  / 3 Years ago, sun, may 30, 2021, 11:58:28

I have an SSH server where users login to do various tasks. The problem is I have 4 cores, and one user is running tasks on 4. How can I limit the number of cores any given user can use?



This is not a virtual machine.



UPDATE:
I was reading /etc/security/limits.conf
and saw



#*               soft    core            0
#root hard core 100000
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#ftp - chroot /ftp
#@student - maxlogins 4


I tried setting this up so that a user is limited to 3 processes.
but the user gets



 -bash: fork: retry: No child processes


in their terminal.



I have started looking into ulimit, and quota


More From » ssh

 Answers
7

taskset(1) may help you. It can set the core number for one process.
You can use ps(1) to get all the process of target user. For example,



housezet@arch: ~
$ ps aux | awk '/^housezet/{print $2}' | xargs -l taskset -p 0x00000001


This wil limit housezet's current process only use one core.
And if limiting cpu usage is also acceptable, you can also consider using cpulimit(1).


[#27084] Monday, May 31, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stantildlike

Total Points: 363
Total Questions: 135
Total Answers: 120

Location: Pitcairn Islands
Member since Fri, Dec 17, 2021
2 Years ago
;