I've posted a question about this few hours ago on Stack Overflow:
Linux bash inline command to execute a program and limit the resource
As I know, to limit the resource I can use ulimit command.
But, the problem is when I set the CPU time limit 1 second, and then I want to execute another program with CPU limit 2s, the ulimit command return an error like this:
bash: ulimit: CPU time: cannot modify limit: Operation not permitted
and absolutely my program killed in 1 second.
So, How can I make the second program running with the CPU time limit 2 seconds?

ulimit -t 1; ./a <input.in> ouput.outand the second oneulimit -t 1; ./b <input.in> output.out– Bobby Stenly May 16 '11 at 14:40