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 3975468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:41:19+00:00 2026-05-20T04:41:19+00:00

I need some advice on a simple bash script. I want to start around

  • 0

I need some advice on a “simple” bash script.

I want to start around 500 instances of a program “myprog”, and kill all of them after x number of seconds

In short, I have a loop that starts the program in background, and after sleep x (number of seconds) pkill is called with the program name.

My questions are:

  1. How can I verify that after 10 seconds all 500 instances are running? ps and grep combination with counting or is there another way?

  2. How can I get a count of how many processes did the pkill (or similar kill functions) actually kill (so that there are not any processes that terminate before the actual timelimit)?

  3. How can one redirect the output of pkill(or similar kill functions) so that it doesn’t output the killed process information, so that 500 lines of ./initializeTest: line 250: 7566 Terminated ./$myprog can be avoided. Redirecting to /dev/null didn’t do the trick.

  • 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-20T04:41:20+00:00Added an answer on May 20, 2026 at 4:41 am

    1,2. Use pgrep. I don’t remember off the top of my head whether pgrep has -c parameter, so you might need to pipe that to wc -l.

    3: that output is produced by your shell’s job control. I think if you run that as a script (not in an interactive shell), there shouldn’t be such an output. For an interactive shell, the are number of ways to turn that off, but they are shell-dependent, so refer to your shell’s manual.

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

Sidebar

Related Questions

I need some advice on how to model this simple categorization (?) example: I
I need some advice as to how I easily can separate test runs for
I need some expect advice on how to handle the following:- I have a
I need some help from the shell-script gurus out there. I have a .txt
need some advice on this one as im struggling abit and cannot figure it
I need some info on how to use margins and how exactly padding works.
I need some software to explore and modify some SQLite databases. Does anything similar
We need some input on what is a good design pattern on using AJAX
I need some sort of interactive chart control for my .NET-based web app. I
I need some basic CMS functionality with rich text editing. On stack overflow there

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.