'Bash script background execution "the input device is not a TTY"

I'm getting the input device is not a TTY errors while the below command is being run in the background of my bash script. I saw a similar issue for docker, yet there is no single post for bash scripts. Is there any other option for running commands in the background other than using &?

echo "Starting the simulation server ..."

cd simulator-server && ./simServer-VegasMixed.sh &


Solution 1:[1]

daemon turns any process into a daemon depending on your script you can try that.

There is always the option of using systemd and creating a service. It really depends on what your script is.

Assuming you are running a linux distro (not BSD etc). Create a file /usr/local/lib/systemd/system/simServer-VegasMixed

[Unit]
Description=simServer VegasMixed


[Service]
Type=simple
ExecStart=/opt/simServer-VegasMixed/simServer-VegasMixed.sh

[Install]
WantedBy=multi-user.target
Alias=simServer.service

That will create a simple service that starts on boot, you can also control the service using

systemctl stop simServer systemctl start simServer systemctl status simServer

If you dont want the service to start on boot, then remove the WantedBy line.

If there is a server/service, then this would be the recommended way to have the service start.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1