As we know,
cgroups can limit cpu usage of processes. Here is an example:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30142 root 20 0 104m 2520 1024 R 99.7 0.1 14:38.97 sh
I have a process, whose pid is 30142. I can limit it as below:
mkdir -p /sys/fs/cgroup/memory/foo echo 1048576 > /cgroup/memory/foo/memory.limit_in_bytes echo 30142 > /cgroup/memory/foo/tasks
As we see, if I want to limit a process, I have to first execute it and then I could limit it according to its pid. Is it possible to limit a process according to its name? Is it possible to limit a process before executing it?