Advise please on scripts

If none of the more specific forums is the right place to ask
Post Reply
Message
Author
gablea
Posts: 23
Joined: 2015-12-26 21:32

Advise please on scripts

#1 Post by gablea »

Hello everyone,

I hope someone can help me with something.

I have created a small script that loads some of the required modules for my EPoS system to work. But. I have a question I want to ask

I start my datasync app with /home/algpos/datasync/datasync.gambas /startsync

Does the script stop processing and wait until the above app exits or does it carry on. I need the script to wait until the app has completed so it can then start the app again but this time in a different mode (I have the /startsync that pulls everything from the server to the local database and then I have /rtsync that sets the application into a screenless mode and sends data to the server every minuite.)

The reason why I need the script to wait is so once the sync app has done the first full download I can then exit the app and then start it like

home/algpos/datasync/datasync.gambas /rtsync &
To put the application into the background (so it's running and keeping the databases in sync with out taking any screen up.

Can I do this or do I need to rethink my approach?

steve_v
Posts: 764
Joined: 2012-10-06 05:31
Location: New Zealand
Has thanked: 2 times
Been thanked: 1 time

Re: Advise please on scripts

#2 Post by steve_v »

gablea wrote: 2021-07-21 22:28Does the script stop processing and wait until the above app exits or does it carry on.
That would depend on exactly how you are starting your subprocess, and whether or not it forks.

You have provided insufficient detail to guess either of those (or even which interpreter your "small script" is running in), so sans crystal-ball, the only advice I can offer is to investigate the posix wait(1P) manual, and the manual for your script interpreter.

By default, bash (guessing) will wait for a subprocess as long as it remains a child process of the invoking shell. If a child process instead runs something in the background and exits, that something will be inherited by init and bash can't track it.
In the latter case you'll probably have to get creative with pidfiles and such.

Post Reply