2

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.

MuscleUpUp
  • 121
  • 2
  • 10
  • 1
    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? – Secespitus Jul 23 '19 at 09: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). – axiac Jul 23 '19 at 09: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 – MuscleUpUp Jul 23 '19 at 09:48

1 Answers1

4

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.

Community
  • 1
  • 1
DrosvarG
  • 483
  • 3
  • 14