Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of ulimit Hard (-H) and Soft (-S)

What does Hard / Soft limits mean?

Difference on core file size for example:
ulimit -Sc 1024 versus ulimit -Hc 1024

I usually put in my script ulimit -c unlimited before running a binary.
However, I want to limit the file size to avoid disk full.
And then I wonder on the best way:

ulimit -Sc 1024  # Soft
ulimit -Hc 1024  # Hard
ulimit  -c 1024  # Both

Another advice: What about the value?
ulimit -c 1024 or ulimit -c 10240 or something else?

like image 357
oHo Avatar asked Feb 01 '12 10:02

oHo


1 Answers

The hard limits are usually intended to be set by the system administrator to the largest value they would be comfortable with a handful of users using.

The soft limits are usually set by the system administrator to the values they'd like everyone to use most of the time. (Consider soft_limit * number_of_users == almost all of the resource available. Leave enough for root to clean up whatever needs to be done, and the users who know how to fiddle with the hard limits to push the boundaries a bit. Sites requiring absolute stability will give hard limits very close to the soft limits.)

If this is the first time you care, I'd just set the soft limits. That gives you the chance to raise or remove them completely in the same session without requiring you to kill that terminal and all its children.

I believe the core size limit is in bytes, so both 1024 and 10240 are way too small for all but the silliest programs. I'd start with $(( 100 * 1024 * 1024 )) for most programs just out of lazyness, but if I knew the program was huge (Firefox) I'd go for much larger still.

like image 151
sarnold Avatar answered Sep 23 '22 13:09

sarnold