systemd limit directives: Set ulimit in RHEL7 or CentOS 7

1. Resource limit directives, their equivalent ulimit shell commands and the unit used

Directive	ulimit equivalent	Unit
LimitCPU=	ulimit -t	Seconds
LimitFSIZE=	ulimit -f	Bytes
LimitDATA=	ulimit -d	Bytes
LimitSTACK=	ulimit -s	Bytes
LimitCORE=	ulimit -c	Bytes
LimitRSS=	ulimit -m	Bytes
LimitNOFILE=	ulimit -n	Number of File Descriptors
LimitAS=	ulimit -v	Bytes
LimitNPROC=	ulimit -u	Number of Processes
LimitMEMLOCK=	ulimit -l	Bytes
LimitLOCKS=	ulimit -x	Number of Locks
LimitSIGPENDING=	ulimit -i	Number of Queued Signals
LimitMSGQUEUE=	ulimit -q	Bytes
LimitNICE=	ulimit -e	Nice Level
LimitRTPRIO=	ulimit -r	Realtime Priority
LimitRTTIME=	No equivalent	Microseconds


2. How to set these limits in CentOS/RHEL 7 ?
We have to put the values in front of LimitCORE, LimitRSS, etc directives to limit the usage or to set as unlimited.

ulimit -v unlimited = LimitAS=infinity
ulimit -m unlimited = LimitRSS=infinity
ulimit -c unlimited = LimitCORE=infinity


3. Where to define these parameters ?
You should be aware where we should define above parameters to define various limits on different parameters.
For this we need to edit the file /usr/lib/systemd/system/SOME_SERVICE.service and define this parameter.

Once the parameter is defined, we need to reload the service to reflect the changes using command “systemctl daemon-reload”.

To understand the complete ulimit systemd directives, we can see the official documentation here.

We can define the limits in /etc/security/limits.conf if we want to define such values based on users or groups.

RHEL7 or Centos 7 provides this additional feature where we can limit resources of a particular service using this concept.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments