• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to set ulimit values for a systemd service

by admin

This post explains how to change the ulimit limits such as the maximum open files for a systemd service. In a CentOS/RHEL 7 or 8 system, the changes done in /etc/security/limits.conf or /etc/security/limits.d/ have no effect on systemd services.

Systemd deliberately ignores the system-wide ulimit settings in order to minimize unintentional or unexpected limit changes caused by shell profiles and scripts.

You can set a new maximum open files limit for a particular service, for example, like this:

1. Identify the name.service file you want in /usr/lib/systemd/system.

2. Copy that file to the /etc/systemd/system directory.

3. Edit the copied file in /etc/systemd/system and add the line:

LimitNOFILE=2048

4. Restart the service:

# systemctl restart [service name]

Update the ulimit values globally for all systemd services

Alternatively, you can update the same limit for ALL systemd services like this:
1. Edit /etc/systemd/system.conf and uncomment the “#DefaultLimitNOFILE=” line, appending the desired number.

2. Reboot the system:

# systemctl reboot

Filed Under: CentOS/RHEL, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How To Separate Each Of Syslog Client’s Messages Into Different File (CentOS/RHEL 6 and 7)
  2. pmap: command not found
  3. How to uninstall rbenv from Ubuntu
  4. exif Command Examples in Linux
  5. After Reboot RAID1 Disk Gets Removed/Out of Sync (CentOS/RHEL)
  6. slapt-src Command Examples in Linux
  7. CentOS/RHEL: /tmp mount point not automatically mounting when added in /etc/fstab
  8. du Command Examples in Linux
  9. How to Install gulp-tslint software package in NPM Packages
  10. Allow root ssh login with public key authentication only

You May Also Like

Primary Sidebar

Recent Posts

  • “az storage blob” Command Examples (Manage blob storage containers and objects in Azure)
  • “az storage account” Command Examples (Manage storage accounts in Azure)
  • “az sshkey” Command Examples (Manage ssh public keys with virtual machines)
  • “az redis” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright