3

I use Ubuntu for Windows 10.

My script (SendTrends.sh) runs all the time but sometimes I need to run antoher script (Historical+.sh) without stopping SendTrends.sh. The best option for me will be if Historical+.sh will poping up in another console and after its work, closes that console. But I will be happy with solution in single console if it will work fine. How can I do that?

Thanks for any kind of help.

3
  • 2
    So you need a new terminal window that displays whatever the second script is doing in order to watch what is happening? Or do you just need to run it, because you mention that it can close directly after finishing? Does your first script need to run in the foreground, or could you send it into the background so that you can still use the consol to occasionally execute the second script? Commented Jul 23, 2019 at 9:35
  • Open another terminal window manually and start the script in it. Or run the script in background and redirect its output to a file (to not interfere with the output of the commands that run in foreground). Then you can check the content of the file while the script is running (and also after it ends). Commented Jul 23, 2019 at 9:43
  • I don't need to display anything form Historical+.sh script but I cant stop the frist script, moreover, it can work in the background when Historical.sh runs Commented Jul 23, 2019 at 9:48

1 Answer 1

5

There is several ways to do this, let me present you some


& shell's control operator

You can use the shell's control operator & at the end of your command: ./Historical+.sh & will launch your script in the background, letting your current console free to use.

You can see more on shell's control operators here.


Run a new bash

There is two ways to do this, one close the console automatically at the end of the execution, and the other keep the bash open. Both have been found in this post (the first in the question, and the second in the accepted answer)

  • Using bash -lic "command" should allow you to launch a new bash, execute the command in it, and then close the created bash.

  • bash --rcfile <(echo '. ~/.bashrc; your_command') is the way to keep the console open


If you only need to run the command and close the console immediately without using it, maybe the solution with the shell's control operator is the more suitable in your case. Else you may consider using one of the two other options.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.