Unix Technical Forum

Change process limits ("ulimit") for cron jobs ?

This is a discussion on Change process limits ("ulimit") for cron jobs ? within the Linux Operating System forums, part of the Unix Operating Systems category; --> Hi, I've a relatively fresh out-of-the-box Suse 9.0 box. I want to set up a job via cron that ...


Go Back   Unix Technical Forum > Unix Operating Systems > Linux Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 08:08 PM
Soeren Gerlach
 
Posts: n/a
Default Change process limits ("ulimit") for cron jobs ?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-17-2008, 08:08 PM
Michael Heiming
 
Posts: n/a
Default Re: Change process limits ("ulimit") for cron jobs ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

In comp.os.linux.setup Soeren Gerlach <soeren@all-about-shift.com> suggested:
> 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

[..]

> 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".


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 zvpunry@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA/gsMAkPEju3Se5QRAjy+AJ0RGdm0R5Y2aNkGXL2zQ+o7uHNW3gC fc9Ic
i4I/Z6vUUQ9dOFiGOjaU5YU=
=Wgg2
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com