"ulimit -v 5000" into the /etc/profile file, so that all users get limited to 5000 bytes of memory when running their programs.
However, I do not want this to apply to root, when he logs in.
Does anyone have any ideas about how I could do this?
I've tried putting:
into /etc/profile, where /bin/limitfile is a script that simply runs 'ulimit -v 5000',
unless the uid of the caller is < 100,
however that has not worked - am I doing it wrong or is there a reason for this?
Suggestions would be very much appreciated.
if [ `/usr/bin/whoami` = 'root' ]
#do stuff special for root
#do stuff only for !root
You should just be able to add "ulimit -v 5000" to the else section of the if block. A quick check of this works on my local workstation, I see no reason why it would fail for a linode. However, when setting ulimit in /etc/profile I believe the limit is per process not per user.
If it seems to be failing, try bumping up the value as a test, when I was playing locally a setting of 2000 would not even let me spawn a shell.
Anywhoo, if it hasn't, would it be a net performance gain to allow, instead of :
max locked memory
all being 5M
and virtual memory being 25M (I have 192M total avalible)…..
Maybe I should set normal memory up to 10M, and virtual mem down to say… 15M?
That would limit the ammount of virtual memory hungry processes were using, and thus, speed up my linode. Is this a good idea?
In my experience (non-linode) artificially limiting any program from using the memory it needs is a reciepe for disaster. Using memory restrictions to keep processes in check so they don't accidentally steal all of the resources is useful, but beyond that the better solutions include either adding more resources or re-engineering the application to run with less resources. Of course while some applications provide configuration level resource usage tweaking such as apache or mysql, most others are beyond the reasonable scope of change.
I just checked your web link, I was thinking of a LAMP host not a shell provider when I wrote that, so it does not apply to your situation very well.
I don't have a lot of experience running as a shell provider without prior knowledge of exactly how they are going to be used to pre-plan memory limits. However, your reasoning of increasing the amount of available running memory and consequently lowering virtual memory seems very reasonable assuming that the average user regularly utilizes more than 5M (bonus points if it is also normally <10M).