I am trying to run screen
in a special way (I am making an unusual script), and it is not working correctly.
My script:
#!/bin/bash
#startserver
set -m
cd /home/USER/SERVER_FOLDER/
screen -Dm -S SERVER java -Xmx768M -Xms768M -jar ./JARFILE.jar $@ &
PID=$!
echo $PID > ./.mc.pid
(sleep 0.5; sudo /usr/bin/oom-priority $PID) &
(wait $PID; startserver_after) &
screen -r $PID.SERVER
/usr/bin/oom-priority
is a coommand I made that sets the priority of the pid to -16
.
startserver_after
is a command I want to run after java
exits.
This isn't working because I cannot resume the screen
. Looking at the screen
manpage:
-D -m This also starts screen in "detached" mode, but doesn't fork a new process. The command exits if the session terminates.
That should mean:
- The
pid
ofscreen
should be the same as that ofjava
, however that works. - It is still
screen
, so I should be able to get to it byscreen -r SERVER
(but I can't).
When I run the line without the ampersand putting it in the background, it just does nothing until java
exits. There is no output.