I have two applications, lets call them APP1 and APP2. I would like that those two execute on parallel on my machine. It is not necessary, that they start at EXACTLY the same time but the should start at roughly the same time. An intial thought was to have a shell script that looks as follows:
./APP1 &
./APP2
Does this the trick or do I need to insert a wait statement to make sure that APP2 starts within a certain time frame?
Thanks
This might be better:
But, as it has been pointed out, shell will start each of these as child processes in a sub-shell. No guarantees are made by the shell about any synchronization between the processes, or about the startup time.
Why do you need these to run in parallel? Perhaps understanding that requirement will get you a better answer.
You could build some very simple startup synchronization into the two programs. Here is the "app1" part of the example.
This will work, and you can even have APP2 start before APP1. If the time is not important but the order is and APP1 MUST start before APP2 then this construction won't give you this guarantee.
You should include a sleep statement if you want to leave a chance to APP1 to run before APP2 is run.
AFAIK shell doesn't guarantee anything about starting times of the programs, but in practice it should start almost at the same time
Your solution should work in practice.. Otherwise you can use any scheduler like at, cron and similar to start both commands at specific time.
That will work fine.