Limit the memory and cpu available for a user in Linux Limit the memory and cpu available for a user in Linux linux linux

Limit the memory and cpu available for a user in Linux


For process related limits, you can have a look in /etc/security/limits.conf (read the comments in the file, use google or use man limits.conf for more information). And as jpalecek points out, you may use ulimit -a to see (and possibly modify) all such limits currently in effect.

You can use the command quota to see if a disk quota is in effect.


You can try running

ulimit -a

to see what resource limits are in effect. Also, if you are allowed to change such limits, you can change them by the ulimit command, eg.

ulimit -c unlimited

lifts any limit for a size of a core file a process can make.


At the C level, the relevant functions (actually syscalls(2)...) could be setrlimit(2) and setpriority(2) and sched_setattr(2). You probably would want them to be called from your shell.

See also proc(5) -and try cat /proc/self/limits and sched(7).

You may want to use the renice(1) command.

If you run a long-lasting program (for several hours) not requiring user interaction, you could consider using some batch processing. Some Linux systems have a batch or at command.