BASH: send SIGTSTP signal (ctrl + z)

I am running against the clock for programming, in which I have to simultaneously run multiple instances of the same program on the same computer. I am currently running instances one at a time by pressing Ctrl + z to pause them and then doing 'bg% # ' to resume execution in the background.

This is very tedious and takes a lot of time so that every time I needed to test a small change in my application, so I want to write a bash script that will run several instances for me, t know how to perform background switching in a script.

Can someone please tell me how can I write a simple script that will run an old command, pause it and resume it in the background?

thanks

+4
source share
2 answers

Do you want to just run in the background? For instance:

mycommand & 

If you want finer-grained control of tasks, you can emulate Ctrl - Z and bg . Control - Z sends SIGTSTP ("tty stop") to the program, which pauses it:

 kill -TSTP [processid] 

And the bg command just sends it SIGCONT :

 kill -CONT [processid] 
+12
source

Not. After the command, you put an ampersand.

 command1 & command2 & command3 & 
+3
source

Source: https://habr.com/ru/post/1403801/


All Articles