Re: [CentOS] Limit RAM used by a perl script

2009-07-21 Thread John Doe
From: Sean Carolan scaro...@gmail.com First, install the perl module BSD::Resource yum install perl-BSD-Resource Then use it in your program like: #!/usr/bin/perl use BSD::Resource; setrlimit(RLIMIT_VMEM, 1_000_000, 1_000_000); # rest of the program that is

Re: [CentOS] Limit RAM used by a perl script

2009-07-21 Thread Sean Carolan
While having hard limits makes it safer, wouldn't it be better to control the memory usage of the script instead of setting limits that would trigger an out of memory...? How would you control the memory usage of the script if it's run by the root user?

Re: [CentOS] Limit RAM used by a perl script

2009-07-21 Thread John Doe
From: Sean Carolan scaro...@gmail.com While having hard limits makes it safer, wouldn't it be better to control the memory usage of the script instead of setting limits that would trigger an out of memory...? How would you control the memory usage of the script if it's run by the

Re: [CentOS] Limit RAM used by a perl script

2009-07-21 Thread Paul Bijnens
On 07/21/2009 04:22 PM, John Doe wrote: From: Sean Carolan scaro...@gmail.com While having hard limits makes it safer, wouldn't it be better to control the memory usage of the script instead of setting limits that would trigger an out of memory...? How would you control the memory usage

Re: [CentOS] Limit RAM used by a perl script

2009-07-21 Thread Sean Carolan
But what if the program's memory use is dependent on lots of factors which are not easily predictable. And you want to avoid bringing the whole system to it's knees while swapping and killing arbritrary other programs while one program is consuming all of ram and swap. In that case it's

[CentOS] Limit RAM used by a perl script

2009-07-20 Thread Sean Carolan
I have a perl script which runs from a cron job. How would you limit the amount of RAM that this script is allowed to consume? Is there a ulimit setting that will accomplish this? If so does ulimit have to be run each time the script is run, or is there a way to set it permanently?

Re: [CentOS] Limit RAM used by a perl script

2009-07-20 Thread luc...@lastdot.org
On Mon, Jul 20, 2009 at 4:28 PM, Sean Carolanscaro...@gmail.com wrote: I have a perl script which runs from a cron job.  How would you limit the amount of RAM that this script is allowed to consume?  Is there a ulimit setting that will accomplish this?  If so does ulimit have to be run each

Re: [CentOS] Limit RAM used by a perl script

2009-07-20 Thread Sean Carolan
If you run it as a regular user, then maybe you can check out /etc/security/limits.conf Currently the script runs as the root user. I may be able to change this, but wanted to find out whether there was some other way first. Would it be possible to use a ulimit command within the perl script

Re: [CentOS] Limit RAM used by a perl script

2009-07-20 Thread Paul Bijnens
On 07/20/2009 05:28 PM, Sean Carolan wrote: I have a perl script which runs from a cron job. How would you limit the amount of RAM that this script is allowed to consume? Is there a ulimit setting that will accomplish this? If so does ulimit have to be run each time the script is run, or is

Re: [CentOS] Limit RAM used by a perl script

2009-07-20 Thread Sean Carolan
First, install the perl module BSD::Resource   yum install perl-BSD-Resource Then use it in your program like:   #!/usr/bin/perl   use BSD::Resource;   setrlimit(RLIMIT_VMEM, 1_000_000, 1_000_000);   # rest of the program that is limited to 1MByte now Thanks, Paul. I knew I'd find an