Error: Cannot fork: Resource temporarily unavailable
Recently my friend (a Developer) came to me with a problem he was facing on his testing server which executing a Perl script. I have checked and found that the Perl script was throwing error “Cannot fork: Resource temporarily unavailable” while executing it.
Cannot fork: Resource temporarily unavailable at /usr/lib/perl5/site_perl/5.8.8/Parallel/ForkManager.pm line 290.
test@server.test.com [~]#
** In above case I am trying to execute the Perl script under user “test“
This problem occurs mainly when you are trying to execute a script with a normal user (or jailshell user but not root) where the Server restricts number of processes should run under a user.
To fix this problem you will have to increase the process limits for the user or you can tell OS to skip the process limits for the user. You will have to edit following files to to ignore the process limits for a particular user.
Open Following files (one by one) in your favorite editor.
- /etc/profile
- /etc/bashrc
- /etc/profile.d/limits.sh
Now search for “if [ “$LIMITUSER” != “root” ]; then” and change it
FROM:
if [ -e “/usr/bin/whoami” ]; then
LIMITUSER=root
fi
if [ “$LIMITUSER” != “root” ]; then
ulimit -n 100 -u 20 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
TO:
LIMITUSER=`/usr/bin/whoami`
fi
if [ “$LIMITUSER” != “root” ] && [ “$LIMITUSER” != “USERNAME” ]; then
ulimit -n 100 -u 35 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
Here, USERNAME is the name of the user under which you are executing the script. In my case I have set the USERNAME to test.
You must log in to post a comment.