Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to execute programs in non-blocking way from scripts

I have series of program files, a.out, b.out, c.out

I want to execute them one after the other after certain delay between each program. like
./a.out -input parameters
----wait for 50 sec----
./b.out -input parameters
-----wait for 100 sec----
./c.out

I want to execute b.out 50 seconds after a.out has started execution but in a non-blocking way i.e. I don't want to wait for 50sec after a.out has finished execution.

Can anyone suggest ways of doing this in linux as I'm putting this into a script that will automate tasks for me

like image 616
cathy Avatar asked Jul 12 '11 14:07

cathy


1 Answers

You want background processes:

./a.out -parameters & 
sleep 50 
./b.out -parameters & 
sleep 100 
./c.out &

Background processes run without blocking your terminal; you can control them in a limited way with the jobs facility.

like image 169
Kilian Foth Avatar answered Sep 27 '22 22:09

Kilian Foth