3

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 &
2
  • In interactive use of bash you can run your script, then Ctrl+Z and type bg to put the job to the background. Once you want to get it to the foreground again, use fg. I'm not sure whether your question includes interactive use case, though. Commented Jan 27, 2022 at 21:22
  • Thanks, Mic, yes indeed my question includes interactive execution. The problem is, I'm using the script for automation installation which shall not require any user interaction . Commented Jan 27, 2022 at 21:24

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This actually helped me while creating a new workflow for Alfred in Mac OS X to open Okular using Docker That was the main command I mainly wanted to run from alfred. docker run -it --rm -e DISPLAY=$mynetip:0 -v /tmp/.X11-unix:/tmp/.X11-unix -v "$HOME/Calibre Library/":"/home/neon" kdeneon/plasma okular
0

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.

2 Comments

Can you please answer the question specifically?
Not without knowing more about the script, and how you want it to run. I am assuming it is a server for a sim, do you want it to start on boot? or manually? Do you want it to restart if it stops or notify you if it stops? Is there any output to the script? Any loggin?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.