Consider a shell script executed by Sh, not Bash (and I can't change it, and can't use a shebang, it's ignored). The & operator works, but disown $! does not and makes Sh complains “disown: not found”.

How do I detach a background process from specifically Sh? I mean, doing from Sh the same as disown do from Bash.

  • 4
    In scripts, disown has no effect anyway (is not needed) – Stéphane Chazelas Jul 31 '14 at 20:20
  • 1
    How no effect? You mean the shell session which launched the background process will close and let the background process continue? You mean I don't need disown or similar at all? – Hibou57 Jul 31 '14 at 20:24
  • 4
    Yes, try sh -c 'sleep 100 &' and see that sleep is still running after sh has returned (sh -c is to run inline scripts). – Stéphane Chazelas Jul 31 '14 at 20:25
  • 1
    I checked it, indeed, it's as you say. So that's strange I had issues with this in the past, and that's due to these issues I wanted to use disown now. I will leave this question open for now and will either complete it or close it, depending on further future cases. – Hibou57 Jul 31 '14 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.