Limiting Processes

I want to restrict programs that are running to a certain memory size, compilation time and running time, is there anyway to do it in the linux environment.

Suppose i have a java program, I want to set a maximum compilation time, a maximum running time and a memory size to run that program. How do i do it?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hugh FraserConsultantCommented:
"ulimit" can meet some of your requirements. It will allow a limit to be placed on elapsed CPU time (but not clock time) and either resident or virtual memory.
ginola29Author Commented:
how do i run ulimit with a java command at the same time? suppose i have a java program named test

am i suppose to do
bash > ulimit ....
bash > java test
Hugh FraserConsultantCommented:
ulimit sets process limits on a shell process and all child processes created by it. Your statement would work, but it will change the limits for your interactive shell, not just the one that created the java process. You want to create a new shell for the java process like this:

sh -c "ulimit ...; java test"

The "sh -c" part says "create a new shell and have it execute the following command.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ginola29Author Commented:
thanks alot, it works perfectly
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.