bash: fork: Resource temporarily unavailable

linuxnewbie

Member
Aug 23, 2002
10
0
151
&bash: fork: Resource temporarily unavailable&

a client (only this 1 guy) gets this message once he is logged in via ssh and tries to run any command.

ex: he types &ls& and he gets the above message

anybody know whats wrong or how to fix this?

thanks
 

Ronny

Well-Known Member
Dec 27, 2002
62
0
156
Well I'd like to have that protection on..... why would it display such a message if the client hasn't done anything? I mean an ls isn't going to cause a fork bomb
 

alareach

Well-Known Member
Aug 12, 2001
57
0
306
follow up?

Any further info on this? Just happened to one of our very long running & stable boxes. Got an email that

/bin/sh: fork: Resource temporarily unavailable

....services started failing, and now can't get into ssh or whm to reboot.
 

Nico

Well-Known Member
Dec 5, 2001
232
0
316
Edmond, OK
Originally posted by linuxnewbie
&bash: fork: Resource temporarily unavailable&

a client (only this 1 guy) gets this message once he is logged in via ssh and tries to run any command.

ex: he types &ls& and he gets the above message

anybody know whats wrong or how to fix this?

thanks
I had this same problem this AM I corrected it like this:
SSH in as root
ps -aux |grep username
(replace username with the user getting this error) You should see all the processes they have running. If you kill those off they can log in afterwards.
 

cornernote

Member
Nov 9, 2003
24
0
156
Hello Chirpy,

I looked at the file but because I don't understand it 100% and I dont want to break it I did not change anything. Would you be able to tell me what I should change?

I tried changing this:
Code:
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 This:
Code:
if [ "$LIMITUSER" == "root" ]; then
        ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
else if [ "$LIMITUSER" == "fasthost" ]; then
        ulimit -n 500 -u 100 -m 1000000 -d 1000000 -s 8192 -c 1000000 -v 1000000 2>/dev/null
else
        ulimit -n 100 -u 20 -m 200000 -d 200000 -s 8192 -c 200000 -v 200000 2>/dev/null
fi

But this results in:
bash: /etc/profile: line 68: syntax error: unexpected end of file



Best regards,
Brett
 
Last edited:

cornernote

Member
Nov 9, 2003
24
0
156
Even if I give my account the same settings as root, it still does the same thing. Yet when I log in as root and "sh" to my user, it works fine.

Brett
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,437
33
473
Go on, have a guess
Looks like you may need to make the change in a few other files, though I don't know which take precedence:

/etc/profile
/etc/bashrc
/etc/profile.d/limits.sh

I cannot say that I've ever tried playing with it, though ;)
 

Norman

Well-Known Member
Sep 20, 2004
88
0
156
FWIW.. I found this with a user.. who when we enabled Fork Bomb Protection, when using IMAP with alot of email accounts would not be able to login via shell.

If you do a "ps -ef | grep <username>" and see a bunch of imapd .. that's one of the reasons.

Just my 2cents worth. :)
 

Devil Inside

Well-Known Member
Apr 4, 2003
276
0
166
I made the changes that were mentioned in this thread - however, I'm still getting the "line 70: syntax error: unexpected end of file" error after changing "else if" to "elif"

Any ideas?
 

npereira

Member
Apr 30, 2003
6
0
151
This was happening on one of my accounts, and I suspended the account, then re-enabled it and all is fine now.... !
 

Abhilash V Nair

Registered
Aug 7, 2006
4
0
151
Hi All,

This thread was helpful to me to a large extent. So I want this thread to be more clear for all who have the same issue and i think this thread will give answer to the previous query .

As Chirpy mentioned we have to make changes on the three files but the changes are same.

the files to be changed are

/etc/profile
/etc/bashrc
/etc/profile.d/limits.sh

As Brett told there will be some what similar lines as given in the quote but the values may have difference.

======================================================================================
if [ "$LIMITUSER" != "root" ]; then
ulimit -n 100 -u 10 -m 100000 -d 100000 -s 8192 -c 100000 -v 100000 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
======================================================================================
The mentioned lines gives unlimited access to the root user but generally there will not be direct ssh acces through root while thinking about security purposes. Here all other users have only limited access. To give unlimited access to a user say 'USER1' chnge this line to

======================================================================================
if [ "$LIMITUSER" = "root" ]; then
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
elif [ "$LIMITUSER" = "USER1" ]; 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
=======================================================================================
This is a very simple change while we think with the logic of if loop. You have to make changes in all the three files mentioned like this. All other users except root and USER1 will have only limited access.

If anyone find anything wrong in this post please point it as I am new to this field.

Really Thanks for Chirpy and Brett as they were the persons who showed me the path to move forward in this case.

Thanks for your time. :)

---
Regards,
Abhilash V Nair
 

xfob

Member
Jul 17, 2007
5
0
51
I Googled this topic for 2.5 hours and found nothing. I wish I had came here first... Thanks for the awesome posts.