-3

I'm new to all of this so I probably made a big rookie mistake. I want to start a screen, which was successful, and then run command, which is not working. When I terminate the screen the command runs, but it needs to be ran on that specific screen. Thank you all in advance.

#!/bin/bash
clear

cd ~/Directory/

screen -S "Screen_Name"; java -Xmx1024M -Xms1024M -jar server.jar nogui
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Agavon
  • 3
  • 2

1 Answers1

0

You have two separate commands, separated by ;. The second command, as you've observed, doesn't run until the first one exits. What you want is to pass the java command and its arguments as arguments to screen.

screen -S "Screen_Name" java -Xmx1024M -Xms1024M -jar server.jar nogui

This will run the java command in the screen session's initial window. When the java command exits, the screen session will terminate as well.

chepner
  • 497,756
  • 71
  • 530
  • 681