How to check the ulimit for another user and change open files

shellulimit

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"
Password: 
$

Best Answer

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.

Specifically:

$ ps -u username  # look up processes owned by user
$ sudo grep 'open files' /proc/${id}/limits  # find "Max open files" line for process ID
Related Question