I am using Fedora linux where ulimit -n 10000 increases file limit upto 10000. I want to achieve the same using java program
How to write java program to increase file limit using ulimit
I have tried with the below program but it didnot work well. The program didnot give any error. but didnot increase file limit also
public class IncreaseFIle {
public static void main(String[] args) {
String command = "/bin/bash ulimit -n 10000";
// String command = "pwd";
try {
Runtime.getRuntime().exec(command);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Thanks
Sunil Kumar Sahoo
From the man page:
The ulimit utility shall set or report the file-size writing limit imposed on files written by the shell and its child processes.You java program is not the shell or one of its child process – it is the ancestor process, and therefore is unaffected by anything that its child process does. To get another ulimit you must somehow contrive to call ulimit before java is started.