Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6758377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:46:46+00:00 2026-05-26T13:46:46+00:00

How do I limit the maximum execution time when executing a java app from

  • 0

How do I limit the maximum execution time when executing a java app from command line, like this:

java -Xmx10G -cp /weka/weka.jar weka.classifiers.trees.J48 -t
/test/test-vector.arff -d /test/test.model

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:46:46+00:00Added an answer on May 26, 2026 at 1:46 pm

    I don’t believe there’s anything built into Java to do this for you. Options:

    • Write a wrapper class which launches the original class but also creates a timer thread to kill the current process if it hasn’t finished in time.
    • Use the operating system capabilities

    As an example of the latter, in bash on Unix-like systems you could use ulimit -t [seconds] before starting the process.

    EDIT: As noted in comments, it’s not clear how graceful such a shutdown with ulimit would be – whether the threads would be killed in a sufficiently polite way to allow finally blocks to execute etc. That’s probably something worth testing out.

    EDIT: Again as per comments, ulimit limits the CPU time, not the overall wall time. This may or may not be what you’re after – it depends if your process is CPU-bound.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FastCGI servers, for example, impose an execution time limit on PHP scripts which cannot
I want to limit the maximum memory used by the JVM. Note, this is
I have few doubts about maximum execution time set in php.ini. Assuming max_execution_time is
I'm looking for a way to limit the maximum number of running processes in
I'd like to limit the size of the file that can be uploaded to
I need to set a maximum limit of rows in my MySQL table. Documentation
I want to limit the maximum size of a HashMap to take metrics on
Is there any way to limit maximum virtual memory usage of javac? When running
With :limit in query, I will get first N records. What is the easiest
I want to limit my users to a directory and its sub directories but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.