Home > Mobile >  Run the same bash script in multiple processes
Run the same bash script in multiple processes

Time:01-31

I have a bash script that basically translates an argument to a kubectl command. For example: $ ./file.sh service1 (will run command kubectl logs service1- -n namespace -f) or $ ./file.sh service2 (will run command kubectl logs service2- -n anothernamespace -f)

My problem is that when I run it to see the logs live with option -f (follow) and I want to open another terminal tab to see the logs from another service with the same script, the first process is killed. So how can I run the same script from multiple terminals without stopping eachother and seeing the output for all.

CodePudding user response:

Run the program in the background and output the log to out.file

command >> out.file 2>&1 &

CodePudding user response:

I did manage to get it working with the help of ChatGPT (it does wonders). The solution is this:

osascript -e 'tell application "Terminal" to do script "clear; ./your_script.sh arg1 arg2" in the front window'
  • Related