5

I want to start a java Process(Minecraft Server) over SSH(PHP Script). And on disconnect it should not be closed.

I am using Bitvise SSH Server for Windows and 64 Bit Java. I can start the server but if I disconnect from the ssh server then the java Process(Minecraft server) stops. I tried with PUTTY but same Problem.

Is there a command for cmd, like screen for Linux, which puts a process in the background?

Thanks.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
Flam3rboy
  • 95
  • 2
  • 7

3 Answers3

7

LK"I

I'm using OpenSSH server for windows. Managed to get it working using this Power shell command:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList C:\path\your-command.exe
Harel Ashwal
  • 1,520
  • 1
  • 14
  • 11
  • This only works for admin users. Non-admin users will get "access denied" because WMI requires interactive logon but ssh is network logon. – Cruise Liu Mar 14 '23 at 10:20
0

Check out this question on Super User: Windows - Run process on background after closing cmd

So what you will do is:

start javaw.exe <arguments>

This will keep the process running after you disconnect from SSH, which will close the CMD session you issued the command.

iBug
  • 35,554
  • 7
  • 89
  • 134
  • 1
    That appears to only work if (and as long as) the user is logged into a Windows desktop session. For me, at least, signing out of Windows also terminates the processes that were opened in the ssh session (from a remote computer). However, the "powershell Invoke-WmiMethod" answer above does seem to keep the process running even after the user has logged out of Windows (and ssh). – NotTheDr01ds Nov 25 '20 at 03:56
0

If you have GNU Coreutils/cygwin installed then you can run start nohup your-command > logfile.txt and it should remain running when you exit the ssh session. This works with the OpenSSH server that comes with Windows 10.

BeechWood
  • 26
  • 4