I have a process running as the gearman user and I want to change open files to avoid getting this nasty error:

ERROR 2014-09-12 17:49:14.000000 [ main ] accept(Too many open files) -> libgearman-server/gearmand.cc:788

How can I run ulimit as another user on Ubuntu and change open files? I don't currently login as gearman but I do have root access. I tried doing this:

su gearman --shell /bin/bash --command "ulimit -n"

as recommended here but nothing get's output:

$ su gearman --shell /bin/bash --command "ulimit -n"

3 Answers 3


Revisiting this just because I stumbled across it during a Google search and found Tony's comment to be useful: while it's true that limits are placed at the process level, the way you would determine the limits in place for a particular user would be to find the processes they've started and then check the proc/${id}/limits.


$ ps -u username  # look up processes owned by user
$ sudo grep 'open files' /proc/${id}/limits  # find "Max open files" line for process ID
  • 2
    This should be the accepted answer, used it to find out the current ulimit for the redis user on Debian.
    – tholu
    Apr 13, 2016 at 13:11

When you run the ulimit command it only affects the process that is running ulimit (the shell) and all subprocesses. So when you run bash --command "ulimit -n", it only affects the number of open files for that instance of bash, then bash exits, thus future processes are not affected.

So to accomplish what you want (to increase the open file limit for your real process), it probably makes more sense to edit limits.conf to boost the open file limit for your specific gearman user.

See examples of limits.conf elsewhere or here.

  • That is also what I found but I'd love to be able to check if it "took effect." I don't get the problem I was having anymore so I'm sure it did
    – Tony
    Sep 14, 2014 at 7:04
  • 12
    This is how you check more /proc/<proc_id>/limits ...maybe worth adding to answer
    – Tony
    Sep 17, 2014 at 4:33
  • 5
    Worth mentioning the location of limits.conf too: /etc/security/limits.conf
    – UpTheCreek
    Nov 4, 2014 at 13:43

Try using su - <USERNAME> -c ulimit' -Hn'. I just tested it on CEntOS 7, and it works.

  • 7
    This won't work if <USERNAME> is unable to login (has the nologin shell).
    – dr_
    May 28, 2019 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.