Skip to content
Advertisement

‘exec(): Unable to fork’ on Ubuntu 14.04.3 LTS

I’m running unittest scripts and for test case setup I need to run shell command from time to time. As a result shell command is run around 50 times during unittest execution.

It works ok on CentOS release 6.6 (Final) server but doesn’t work on Ubuntu 14.04.3 LTS.

The problem is that after around 20th time shell script execution I get the following error:

JavaScript

I’ve checked all the topics around the internet and no one helped me. I’ve increased process number and open files limit to enormous values

JavaScript

PHP reports similar numbers. (file test.php contains <?php echo system("ulimit -a");)

JavaScript

I run scripts as a non-root user from CLI.

I’ve increased php memory size to 2Gb

JavaScript

I’ve tried to use system, passthrough, shel_exec and it makes not difference.

PHP version is 5.6

JavaScript

Does anybody know how to solve the problem?

Advertisement

Answer

The issue in my case was very simple and not related to configuration changes I’ve done. I think it is reasonable to keep my experience here so that it can help other developers to avoid the same issues.

The problem was in lack of memory on server. It was virtual machine with 1Gb RAM. When script memory usage was around 700Mb it start failing with ‘unable to fork’ error. Which is strange and doesn’t sound like memory issues.

Increasing server’s memory size up to 4Gb solved the issue.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement