Home > front end >  Bash script background execution "the input device is not a TTY"
Bash script background execution "the input device is not a TTY"

Time:01-29

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 &

CodePudding user response:

I have finally figured it out! I used tmux to run my command in separate sessions.

tmux new -d './simServer-VegasMixed.sh'

This post has also helped me a lot in solving my problem.

CodePudding user response:

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.

  •  Tags:  
  • Related