fork: resource temporarily unavailable ???

January 21, 2010 • By admincPanel

If you are getting Linux error message, Resource temporarily unavailable, it’s because your system is limiting the number of files / processes / CPU that your particular user ID can use.

If you use WHM/Cpanel, enabling the “Shell fork bomb protection” can make the “Resource temporarily unavailable” message appear more often. You may get rid of this message by disabling Shell Fork Bomb Protection.  However, that is a major security issue. Enabling it is a good thing. After all, do you want any jackass user to be able to write a perl script containing the line “while (fork());” and bring your system to its knees?

Instead, consider raising the limits for individual trusted users using ulimit. (You will need root access to do this.)

Make the following changes in the system shell init files.

These files:
/etc/profile
/etc/bashrc
/etc/profile.d/limits.sh

if [ "$LIMITUSER" = "root" ]; then
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
elif [ "$LIMITUSER" = "YOUR USER NAME" ]; then
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
else
ulimit -n 100 -u 20 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
fi


Alternate Solution

To fix this, first you have to turn off cPanel’s built in ‘Prevent Shell Fork Bomb Protection’. Then, edit the /etc/security/limits.conf.  Increase the limit by by putting/changing the following line:

*             soft     nproc     20
someone        soft     nproc     40
root          soft     nproc     unlimited

It will limit to 20 processes for all users except someone and root. User someone and root will enjoy maximum of 40 and unlimited simulteneous processes.

The key is turning off cPanel’s internal protection so your box will use this file.

fork: resource temporarily unavailable ??? , 10.0 out of 10 based on 1 rating