A Bash Script Run Over SSH Will Not Keep Running
Just now, TheCoder2019 said:Is there a way I can keep my server open without having command prompt open all the time?
This is how SSH works. You open a separate terminal instance in which your commands are run, and when you close out ssh, the terminal is closed as is everything spawned in it.
The solution I've found to be easiest is using screen, which you can install through any default package manager for the most part. Once installed, you just run
screen [command you want to run]
so, in your case, I would run
screen ./script.sh
or whatever your script's name/extension is, then it'll clear the screen and spawn a new, detachable terminal instance you can disconnect from and reconnect to at will. If you disconnect from the instance (you press ctrl+a, then press d) or close out of the ssh shell, you can reconnect by running
screen -r
and you'll be good to go. As always, be sure to read up on it so you understand it well enough, but it's what I've been using to manage my Minecraft server instances over ssh for years now with very little extra hassle.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now