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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:36:32+00:00 2026-06-12T20:36:32+00:00

I have a script that runs other scripts with source. What i want to

  • 0

I have a script that runs other scripts with source. What i want to do is to find those scripts being run, and if any of them is running, then stop executing it.
Something like this:

 #!/bin/bash

 source /path/script1.sh
 source /path/sript2.sh
 source /path/sript3.sh

 if [ a_script_is_running ]
 then
      stop_execution scriptn.sh
 fi

If one of those scripts was running an infinite loop, is there a way to stop this loop and to continue with the execution of the main script?

  • 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-12T20:36:33+00:00Added an answer on June 12, 2026 at 8:36 pm

    What you are looking for is background shells and how to kill them.

    The first step is to fork those scripts into the background instead of sourcing them. Sourcing them just inserts their code into your current script.

    So you could do something like:

    # '&' forks a script into the background
    /path/script1.sh &
    /path/script2.sh &
    /path/script3.sh &
    ...
    # now when you need to make sure that they are all killed
    kill $(jobs -p)
    

    Explanation of source

    If I have 3 scripts:

    script.1.sh:

    echo "hello world"
    

    script.2.sh:

    source script.1.sh
    source script.1.sh
    

    script.3.sh:

    echo "hello world"
    echo "hello world"
    

    There is no functional difference between script.3.sh and script.2.sh. None. They both will use one shell process (echo is builtin) and will call echo “hello world” twice one after the other.

    script4.sh:

    script.1.sh &
    script.1.sh &
    

    This one is different. It forks two background scripts (both called script.1.sh although they will have different process IDs), each of those background processes will echo “hello world” and then exit. It will look the same, but in this case you could actually kill one of them since they are executing asynchronously from your main script.

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

Sidebar

Related Questions

I have a main script that is running other scripts and loading the variables
We have a powershell build script that calls out to other scripts that is
I have a couple of bash scripts that I want to make sure runs
I have a script that runs great in IE 9+ and all other browsers.
I have a script that runs every two minutes for a Tweet-getter application. In
I have a script that runs every minute at XX:00. The script loops over
I have a script that runs at evening, it writes to a log file
I have a python script that runs a program, which generates few .exe files
I have a JScript script that runs using cscript.exe . It creates a shortcut
I have a python script that runs on a cron job. The script uses

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.