• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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?
0
ginola29
Asked:
ginola29
  • 2
  • 2
1 Solution
 
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.
0
 
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
??
0
 
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.
0
 
ginola29Author Commented:
thanks alot, it works perfectly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now