Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash fork error (Resource temporarily unavailable) does not stop, and keeps showing up every time I try to kill/reboot

I mistakenly used a limited server as an iperf server for 5000 parallel connections. (limit is 1024 processes) Now every time I log in, I see this:

-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable

Then, I try to kill them, but when I do ps, I get this:

-bash-4.1$ ps
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable

Same happens when I do a killall or similar things. I have even tried to reboot the system but again this is what I get after reboot:

-bash-4.1$ sudo reboot
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash-4.1$ 

So Basically I cannot do anything. all the commands get this error :/ I can, however, do "exit".

This is an off-site server that I do not have physical access to, so I cannot turn it off/on physically.

Any ideas how I can fix this problem? I highly appreciate any help.

like image 824
user2662165 Avatar asked Feb 28 '14 20:02

user2662165


People also ask

How do I fix bash Fork retry Resource temporarily unavailable?

Answer. This could be resolved by the system administrator by increasing the number of user processes. The most common way to resolve this is by using the ulimit command, and specifying a larger value than currently present.

Can t fork process resource temporarily unavailable?

Root Cause There can be various reasons for processes not being able to fork: There is a misbehaving service or process running, consuming more resources than expected. The system was not able to create new processes, because of the limits set for nproc in /etc/security/limits.

What(): resource temporarily unavailable?

"Resource temporarily unavailable" is the error message corresponding to EAGAIN , which means that the operation would have blocked but nonblocking operation was requested.

What Errno 11?

Errno 11 (EAGAIN) means the resource is temporarily unavailable. The call might work if tried again later. The number of processes reached 1024. The number of current processes is around 950. The database continues working.


2 Answers

Given that you can login, you may want to try using exec to execute all your commands. After executing exec you will have to log in again, since exec will kill your shell (by replacing it with the command you run).

exec won't take up an extra process slot because it will replaces the running shell with the program to run. Thus, it should be able to bypass the ulimit restriction.

like image 173
nneonneo Avatar answered Sep 22 '22 05:09

nneonneo


I had the same issue recently. In my case the reason was there was code that was executing under my ownership and consumed almost all the resources leaving nothing for my commands. Here's what I did, "exec top" to identify the PID thats consuming maximum resources "exec kill -9 " killing the PID identified by above command.

After killing the PID, everything came back to normal and I was able to login back.

like image 26
MYD Avatar answered Sep 20 '22 05:09

MYD