sleep in upstart script (upstart synchronism)

Yes, somehow, sleep doesn't work for me either (I'm using Ubuntu 10.04). I'm not sure that the following solution is the best one but it seems to be working.

  1. Create an additional upstart task, say, post-sleep.conf (logging added for clarity):

    description "Sleep when the job finishes"
    
    task
    
    script
        echo "Sleeping..." | logger -t "post-sleep-job"
        /bin/sleep 60s
        echo "Done sleeping" | logger -t "post-sleep-job"
    end script
    
  2. Add the following to the job that needs to sleep after shutdown:

    post-stop script
        start post-sleep
    end script
    

Use instances in the first script if several jobs need to wait before full shutdown. However, I think an even better and more robust solution would be to rely on events.