0

I have a script that does several things, one of which depends on availability of a local mount of a remove directory. The first command in the script makes sure the remote disk is locally mounted by calling another with &. The next several things do not require the remote disk, hence the background &.

But recently, it seems the mounting is a bit slow and the last thing in the script fails because the remote files are not available.

What is a good way to pause until the remote files are available?

I thought fg would bring the task back to the foreground and go to the next line when the task finishes. But it said "no job control in this shell"

I think it would work on any Linux or BSD, but if it matters, this is zsh on MacOS (BSD but POSIX certified). Have bash and csh available if that's what it takes.

I can do a loop checking availability of a known remote file, but perhaps there's a better way.

0

1 Answer 1

0
   wait

The wait command will wait until the background processes are finished before continuing to process the script. Simply add it to the script at the point before you need to access the mounts.

1
  • man wait on my system says it is in sh and csh. man zshbuiltins says it is in zsh. So that sounds like the simplest approach; testing … test passed. Thanks!
    – WGroleau
    Dec 6, 2022 at 4:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .