DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd May 2008
EricM EricM is offline
New User
 
Join Date: May 2008
Posts: 6
Thanked 0 Times in 0 Posts
Default login.conf memoryuse not working

I am trying to set a memory limit so that any process using more then the limit I set gets killed or otherwise not allowed to allocate any more memory.

I followed the instructions on
http://www.freebsd.org/cgi/man.cgi?q...conf&sektion=5

edited /etc/login.conf

In the default class i changed
:memoryuse=unlimited:\
to
:memoryuse=150M:\

then run
cap_mkdb /etc/login.conf

I can still run processes that are using more then 150MB memory and nothing happens.

What did I do wrong?

Im running FreeBSD 6.0-RELEASE
Reply With Quote
  #2   (View Single Post)  
Old 22nd May 2008
cajunman4life cajunman4life is offline
Real Name: Aaron Graves
Package Pilot
 
Join Date: May 2008
Location: Coolidge, Arizona
Posts: 203
Thanked 16 Times in 14 Posts
Default

The problem is (at least this was the case for me) that even though that's the "default" class, the users you create on your system (by default) belong to no class.

What can be done is run (as root) chsh <username>, and find the section "Class:". You'll notice there is no entry there. Type "default" after the "Class:" (don't forget a space after the colon) and save that entry. A quick logout-then-back-in for the user affected (after cap_mkdb of course) and the new limits should be in effect.

Let me know if this solved your problem.
__________________
I just saved a bunch of money on my car insurance by fleeing the scene of the accident!
Reply With Quote
  #3   (View Single Post)  
Old 22nd May 2008
EricM EricM is offline
New User
 
Join Date: May 2008
Posts: 6
Thanked 0 Times in 0 Posts
Default

Ive already tried editing the class of the user and no difference.

If it makes any difference im trying to limit the memory usage of apache, which starts as root and then changes uid to nobody.

So changed the class of user "nobody" to put the memory limit, doesnt work.

Does login.conf only apply to users who login (via ssh etc..) or to all processes running under that username no matter how they were started?
Reply With Quote
  #4   (View Single Post)  
Old 22nd May 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

I can't say I'm very smart on login.conf but, su allows you to define the login class used when called as root. For example, on my test machine I start mysqld by executing the following:

Code:
su -c _mysql root -c '/usr/local/bin/mysqld_safe >/dev/null 2>&1 &'

Where _mysql is the login class, root is the user to launch it initially and the second -c is passed onto /bin/sh along with it's arguments.


You might find it a useful trick. Although I've never tried to push the limits I've had no probs; here is the login.conf entry for good measure:

Code:
#
# This class is used when running MySQL from /etc/rc.local
# XXX: It will *N_O_T* be used when starting/stopping mysqld manually!!
#
_mysql:\
        :ignorenologin:\
        :datasize=infinity:\
        :maxproc=infinity:\
        :openfiles=3580:\       # I've set this to sysctl::kern.maxfiles
        :stacksize-cur=8M:\
        :localcipher=blowfish,8:\
        :tc=daemon:
footnote: it's running off an OpenBSD 4.3 machine
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #5   (View Single Post)  
Old 22nd May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

Quote:
Originally Posted by EricM View Post
I am trying to set a memory limit so that any process using more then the limit I set gets killed or otherwise not allowed to allocate any more memory.

I followed the instructions on
http://www.freebsd.org/cgi/man.cgi?q...conf&sektion=5

edited /etc/login.conf

In the default class i changed
:memoryuse=unlimited:\
to
:memoryuse=150M:\

then run
cap_mkdb /etc/login.conf

I can still run processes that are using more then 150MB memory and nothing happens.

What did I do wrong?

Im running FreeBSD 6.0-RELEASE
from what i infer from the man pages, 'memoryuse' comes into play only when the system runs low on memory in which case the kernel will start paging out the processes which have exceeded their RLIMIT_RSS limit (see getrlimit(2)).
i reckon this could be used to prioritize/ration memory b/w apps for low memory situations.

if you want a cap on mem. then set limits for data, stack and virt. add. space usage.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
some login.conf questions gosha OpenBSD General 2 5th July 2009 12:43 PM
Login automatically map7 FreeBSD General 1 12th October 2008 11:09 PM
difference between rc.conf and loader.conf disappearedng FreeBSD General 5 3rd September 2008 05:54 AM
How can i login to my FreeBSD ?? ceramic FreeBSD Installation and Upgrading 4 28th July 2008 11:56 AM
How to set up ssh login cssgalactic FreeBSD General 12 28th June 2008 06:00 PM


All times are GMT. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick