11

How do i increase the file limit for the asterisk daemon on my ubuntu computer? When I login as root and use the ulimit, it says unlimited already. I can't login as asterisk because that user doesn't have shell access, it's just a daemon.

I can see in /proc/<asterisk proc id>/limits the current Max open files is 1024. I want to double that.

I even went into /etc/security/limit.conf and added

asterisk soft nofile 2048
asterisk hard nofile 2048
@asterisk soft nofile 2048
@asterisk hard nofile 2048

THen I reboot server. Still, the max open files is 1024.

What else can I do?

6 Answers 6

5

You could always edit the /etc/init.d/asterisk file and prepend ulimit -n 2048 to the top.

This is the same process that MySQL, Varnish and a few others use.

3
  • superb!!! it wored May 18, 2013 at 12:28
  • @Ben Lessani. May i know where to paste 'ulimit -n 2048' in /etc/init.d/asterisk file. Inside start function or outside all methods? Jan 19, 2016 at 10:57
  • At the top of the script, after the LSB data Jan 19, 2016 at 10:58
3

For Asterisk running under systemd (e.g. on Debian 9), you need to create a systemd override file:

mkdir /etc/systemd/system/asterisk.service.d/

Create /etc/systemd/system/asterisk.service.d/override.conf with the following contents:

[Service]
LimitNOFILE=100000

Reload the unit:

systemctl daemon-reload

Restart Asterisk:

systemctl restart astertisk

Check the limit:

cat /proc/<your asterisk PID>/limits | grep '^Max open files'
2

I had this exact issue for anyone stumbling across this in the future (is it chrome?)

The system that I was having the issue on was Debian rather than Ubuntu, but hey, close enough.

I had to use the following in '/etc/security/limits.conf' to get it working, as specifying the user & group didn't work.

*               soft    nofile          10240
*               hard    nofile          10240

Logging in and out again applies this change.

1
  • What does logging in and out have to do with a specific running daemon? Do you mean "restart the service", or...?
    – Tom Wadley
    Sep 19, 2014 at 10:05
2

In Asterisk 11 (I've not checked others) this is set with the maxfiles directive in the [general] section of asterisk.conf. None of the other answers worked for me on Debian.

1

It is better to edit the configurations in /usr/sbin/safe_asterisk instead on editing init.d script.

you can set many parameters (PRIORITY, SYSMAXFILES, MAXFILES ...). Uncomment SYSMAXFILES and MAXFILES; and increase their values.

3
  • Directly edit the executable? Then the changes will be lost the next time the executable gets updated. Configuration changes should go in config files. Nov 21, 2014 at 16:22
  • That's no more of an executable than is /etc/rc.d/init.d/asterisk which was accepted, so, have an upvote. I find this method to be rather reliable.
    – dougBTV
    Aug 20, 2015 at 19:13
  • @ItsMe; I Think you have the best answer, i have tried all other alternatives without success, but your solution is radical and clean. Thank's
    – elhadi d
    Nov 30, 2016 at 8:43
1

Here is an easy way to increase ulimit value in asterisk.

Go to this file. /etc/asterisk/asterisk.conf

[options]
internal_timing = no
maxfiles = 999999

paste above line is asterisk.conf file then execute below commands.

asterisk -rx "core restart now"
asterisk -rx "ulimit descriptors"

Output

Number of file descriptors (descriptors) is limited to 999999.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .