2017-11-19 19:52:40 UTC
I want to raise the "number of files" limits for the user instance.
First, I set DefaultLimitNOFILE to something higher than the global system
default in /etc/systemd/user.conf and I rebooted.
Then I confirmed that the setting has taken effect:
"systemctl --user show" showed the new DefaultLimitNOFILE and the unit
itself showed the higher setting of LimitNOFILE when I ran "systemctl
--user show foo".
So far everything worked as expected.
However, when I checked "cat /proc/<pid>/limits" on the ExecStart process
of foo.service, I don't see the "number of files" limit has changed.
What did I do wrong?
Second question: if I want to raise the limit just for a single user, how
would I go about it?
Making a change in user.conf would make it apply in all user instances
(assuming I could get it to work).
I have found that if I create /etc/systemd/system/user@<uid>.service and
add LimitNOFILE to the [Service] section of that file, then it will do two
things. First, it actually works whereas editing user.conf did not. Second,
the change only applies to user <uid> and not all users.
I assume I'm not getting how systemd is supposed to work. So please
Machine stats (although I see the same behavior on Ubuntu and on Centos7.3):
$ systemctl --version
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN
$ uname -a
Linux foo-ubuntu-vm1 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03
UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS