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

  • SEARCH
  • Home
  • 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 9148865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:23:24+00:00 2026-06-17T11:23:24+00:00

I am trying to run some computational-intense program from Ruby via the following command:

  • 0

I am trying to run some computational-intense program from Ruby via the following command:

%x(heavy_program)

However, I sometimes want to limit the running time of the program. So I tried doing

%x(ulimit -St #{max_time} & heavy_program)

But it seems to fail; the “&” trick does not work even when I try it in a running sh shell outside Ruby.

I’m sure there’s a better way of doing this…

  • 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-06-17T11:23:24+00:00Added an answer on June 17, 2026 at 11:23 am

    use either && or ;:

    %x(ulimit -St #{max_time} && heavy_program)
    
    %x(ulimit -St #{max_time}; heavy_program)
    

    However using ulimit may be not what you really need, consider this code:

    require 'timeout'
    Timeout(max_time){ %x'heavy_program' }
    

    ulimit limits CPU time, and timeout limits total running time, as we, humans, usually count it.

    so, for example, if you run sleep 999999 shell command with ulimit -St 5 – it will run not for 5 seconds, but for all 999999 because sleep uses negligible amount of CPU time

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

Sidebar

Related Questions

I'm trying to run some third party bash scripts from within my ruby program.
I am trying to run some classification using weka from the command line. In
I am trying to run some acceptance tests for javascript code. However, when I
I'm trying to run some MPI programs in xcode 4. I installed openmpi from
I'm trying to run the following program, which calculates roots of polynomials of degree
Trying to run some sql in a pl/sql procedure. Select field from schema.view; I
I'm trying to run some server only code from an event on the client
I am trying to run some code from a book . There appears to
I am trying to run some scripts from C# and I have a script
I am trying to run some of the sample example code from CGAL as

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.