How to be notified when a script's background job completes?

Posted by Keith Bentrup on Stack Overflow See other posts from Stack Overflow or by Keith Bentrup
Published on 2010-05-08T20:06:34Z Indexed on 2010/05/08 20:18 UTC
Read the original article Hit count: 235

Filed under:
|
|
|
|

My question is very similar to this one except that my background process was started from a script. I could be doing something wrong but when I try this simple example:

#!/bin/bash
set -mb  # enable job control and notification
sleep 5  &

I never receive notification when the sleep background command finishes. However, if I execute the same directly in the terminal,

$ set -mb  
$ sleep 5  &
[1]+  Done                    sleep 5

I see the output that I expect.

I'm using bash on cygwin. I'm guessing that it might have something to do with where the output is directed, but trying various output redirection, I'm not getting any closer?

© Stack Overflow or respective owner

Related posts about bash

Related posts about notify