Nohup: cannot disconnect from console

I have a bash script that will work on both Linux and Mac OS X. One particular line of script works the same as on Linux, but not on OS X.

nohup <utility> <arg> > output.txt 2> error.txt </dev/null &

When a bash script runs on Linux, it works like a charm. However, running a bash script on OS X, I get an error

nohup: can't detach from console: Inappropriate ioctl for device

I searched a lot and did not find a suitable answer about why this behaves as such.

The script execution ends long before <utility>that, so (as far as I know) I need to use nohup. However, I did some testing, and removing nohupfrom a line in a bash script seems like the trick is that the utility will start on both systems and continue to work even after the script exits.

+4
source share
1 answer

try the following:

nohup <utility> <arg> > output.txt 2> error.txt >/dev/null &
0
source

Source: https://habr.com/ru/post/1542235/


All Articles