Find and resume task/process in cmd over ssh

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Test_user
Posts: 1
Joined: 27 Mar 2020 07:07

Find and resume task/process in cmd over ssh

#1 Post by Test_user » 27 Mar 2020 07:18

I have recently put together a computer that I placed at a friends house on which I am running a Minecraft server, I will Call this computer B. Since I want to get better using CMD i am starting and running this server entierly via CMD on that computer.

How the setup looks currently is that I connect to computer B via my own computer (computer A) that is on another network (my own network that is). I then start the server by navigating to the ServerStart.bat file and it runs without any issues. Alright, everything is working great so far, but here is the tricky part. When I then "exit" the ssh session and later connect again i am placed in C:\Users\[My user]\ with no running server.

My question is wether it is possible to find the "server process" and view it again as one would normally open a window if they used the windows gui.

I don't know much about cmd and that is probably painfully obvious from the question. I apologize for this and I am very thankful for any and all advice!

jeb
Expert
Posts: 967
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Find and resume task/process in cmd over ssh

#2 Post by jeb » 27 Mar 2020 07:45

Hi,

there are some questions left.
You are using a windows on both computers, but you are also using ssh to connect from one computer to the other.
I'm assume, you have installed something like OpenSSH on one computer (server) and connect by using putty or openssh.
But in both cases, I would expect that you are on a bash shell, not on a cmd.exe instance.

Your main problem seems to be the fact, that closing your ssh session will also close all subprocesses.
Even if you could avoid the killing of the process you have the problem of reconnect to the same session.

But there exists solutions (at least for the linux world) with screen or tmux.
If you install screen (on the server), then you could connect to the server via ssh.
For the first time you starting a new screen session and give it a name.

If you disconnect and later reconnect to the server, the screen session is still available and you can attach to that session again.

Code: Select all

# First Time, create a new session
screen -S mySeesion
# In that session, start your server

# Later, after a reconnect, attach to that session by
screen -rx -S mySession

Post Reply