Reputation: 5416
I am running a script a.sh and parallelly I am executing b.sh. Now b.sh should not start executing it's business logic unless a.sh is finished. To achieve that in b.sh, I have a while loop which searches with the name a.sh in ps -ef command, but a.sh has many sleep commands, so when sleep is executing I am not seeing any result in ps -ef command for a.sh, rather the process is like sleep 60
In this scenario, what I can think of is either I set a flag in a.sh which b.sh can access somehow. But I don't know how to access such variable in b.sh because a.sh is not calling b.sh.
Or I can create a child process and give it a custom name and terminate it in the end of a.sh.
In such way, in b.sh I can search for the process with that particular name and till the time it is there I don;t start execution of the business logic in b.sh. But I don't know how to do this either.
Upvotes: 0
Views: 56
Reputation: 154
Why not let the 2 communicate? For example what you could do :
Note that there might be some easier/safer way to do that in bash (using signals maybe) but I think that should do the job. Be careful though about the concurrent aspect of your problem.
(can't comment not enough rep)
Upvotes: 1