[PLUG] question on obtaining the PID numbers of a batch command and finding out when a batch script has successfully terminated
Michael Ewan
michaelewan15 at gmail.com
Mon Oct 7 16:10:12 UTC 2024
If you want the PID, then 'ps -efww' will show the entire command line
rather than just 'bash', then pipe to grep to get the specific instance.
In your script you should use 'wait' which is a bash builtin that will wait
for all background processes to exit.
On Sun, Oct 6, 2024 at 6:25 PM American Citizen <website.reader3 at gmail.com>
wrote:
> To all:
>
> I have a simple batch file which has 6 CLI commands to it
>
> gp -q < xaa > xaa.results &
>
> gp -q < xab > xab.results &
>
> gp -q < xac > xac.results &
>
> gp -q < xad > xad.results &
>
> gp -q < xae > xae.results &
>
> gp -q < xaf > xaf.results &
>
> When I do a simple "% bash do-x.sh" which is the bash script, it runs
> normally
>
> but due to the redirect commands, doing the "ps -fx" will only return
> the gp command (along with all live commands the system is running) but
> I don't know which xaa, or xab, or xac, etc it is associated with.
>
> Is there some way to do a "ps -fax | grep gp" command which locates
> exactly the pids involved? And can these results be returned as a simple
> ascii file, so I can do future inquiries to determine when the program
> has stopped running?
>
> The goal here is to determine when all 6 programs running "gp" have
> terminated.
>
> Randall
>
>
>
More information about the PLUG
mailing list