0

I have a shell script which runs very large simulation binaries. This becomes problematic when I want to request some output of variables in the script. For instance, when I run 10 large simulations, I want to be able to print which iteration I am on without having to wait a minute or two for the current simulation to terminate.

Currently, I am using the trap command. However, the script does not react immediately to signals but will only execute the binded function when the current iteration terminates. I will post the code if anyone needs it.

1 Answer 1

1

You should start threads for each large thing you're going to run. Have those threads dump results somewhere, then you have your main method free waiting to interrogate the results on the fly.

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

3 Comments

Hmm, would it be better to just create one thread which does the simulations instead of spawning a new one for each? Because the order matters and if I spawn multiple threads per run, then the order cannot be guaranteed.
In addition, when mentioning threads, I have not found any tutorials about it. Are you talking about &? I thought that was for a separate process.
It is. Shell scripts do not use threads; they can only start additional processes.

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.