There is a simple script to run the processes of numbers given to me:
#! / Bin / bash # Usage: ./run-abt.sh & lt; Agent Count & gt; & Lt; Respondent Port & gt; & Lt; Publisher Port & gt; Echo "./abt-monitor 127.0.0.1 $ 2 $ 3 $ 1" exec./abt-monitor 127.0.0.1 $ 2 $ 3 $ 1 & amp; For ((i = 1; i & lt; = $ 1; i ++)) "Run Agent $ i" resonates; Exec ./abt-agent 127.0.0.1 $ 2 $ 3 $ i $ 1 & gt; $ I.txt & amp; I need to be added when users press Ctrl + C and return control, created by run-abt.sh
To kill all the processes , add this script to the beginning of your script:
trap 'kill $ (jobs-p)' xit When your script is for Control-C (or for any other signal, or any other signal Interrupt signal from) If it is received, then it will end all the children before the completion of the procedures, at the end of the script, add a call to wait so that the script can automatically get out), so that the signal handler There is a chance to run upstairs installed. That is, for ((i = 1; i & lt; = $ 1; i ++)) "Running agent $ i" resonates; Exec ./abt-agent 127.0.0.1 $ 2 $ 3 $ i $ 1 & gt; $ I.txt & amp; # There may be more code here but before the script naturally exits, wait ...
No comments:
Post a Comment