Discussion:
Change process limits ("ulimit") for cron jobs ?
(too old to reply)
Soeren Gerlach
2004-07-20 22:18:25 UTC
Permalink
Hi,

I've a relatively fresh out-of-the-box Suse 9.0 box. I want to set up
a job via cron that starts an application with up to 1800 java
threads; java threads are mapped as processes so the application needs
to be allowed to run 1800 processes.

I changed /etc/security.limits.conf

* hard nofile 8192
* hard nproc 8192

THIS should really be enough ,-) And I added the following line to
/etc/pam.d/login as well as /etc/pam.d/sshd (the later one for
testing, see below)

session required pam_limits.so debug


My problem is now that a simple cronjob, where I can test this, does
not work as supposed:

( ulimit -a ; echo ; ulimit -n 4096 ; echo ; ulimit -a ) 2>&1 | mail
foobar

results in an error message "/bin/sh: line 1: ulimit: open files:
cannot modify limit: Operation not permitted".

Funny enough: If I login via ssh it's not a problem, works like a
charm. Also while using sshd I can see from the log file, that the
limits module really is pulling the settings out of the limits.conf
file so I suppose the mechanism itself work.
Naive like I am I tried to add the above line to a newly create file
/etc/pam.d/cron (and "crond" as well) but this did not helped
anything.

So...what the bl**dy hell am I doing wrong?


Thanks a lot,
Soeren Gerlach
Michael Heiming
2004-07-21 06:19:57 UTC
Permalink
NotDashEscaped: You need GnuPG to verify this message
Post by Soeren Gerlach
Hi,
I've a relatively fresh out-of-the-box Suse 9.0 box. I want to set up
a job via cron that starts an application with up to 1800 java
threads; java threads are mapped as processes so the application needs
to be allowed to run 1800 processes.
I changed /etc/security.limits.conf
* hard nofile 8192
* hard nproc 8192
[..]
Post by Soeren Gerlach
My problem is now that a simple cronjob, where I can test this, does
( ulimit -a ; echo ; ulimit -n 4096 ; echo ; ulimit -a ) 2>&1 | mail
foobar
cannot modify limit: Operation not permitted".
Yup, some versions of cron do not seem to honor limits.conf, you
could put in your /etc/init.d/crond, before cron starts:

ulimit -Hn 8192
ulimit -Sn 8192
ulimit -Hu 8192
ulimit -Su 8192

Restart crond and see if this works better, not a very nice
approach.
--
Michael Heiming (GPG-Key ID: 0xEDD27B94)
mail: echo ***@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
Loading...