0

Hi I have a problem with a solution to my previous question about getting something to check if the server is started.

So when I use Pgrep -f in my startup script to check if the MC server is running, it does the job, but after multiple restarts the terminal window starts showing pid numbers instead of the actual Minecraft commandline. This was not a problem before since I used to run it with GUI which I don't do anymore.

Picture of my commandline after 3 restarts

My startup script looks like this

#!/bin/sh
while true
do
    if ! pgrep -f server.jar
    then
        java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 - 
        XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch - 
        XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M - 
        XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 - 
        XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 - 
        XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem - 
        XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true 
        -jar server.jar --nogui
    fi
    sleep 5
done
  • So If I understand correctly this should solve my problem ">/dev/null" But will it only affect pgrep? – GVK AWESOME Feb 22 '21 at 21:05
  • 1
    If you do `pgrep -f server.jar >/dev/null`, yes. – tink Feb 22 '21 at 21:06
  • error (and possibly warning) messages are written to the std-err stream, so you may need `.... >/dev/null 2>&1`, which will alos redirect std-err to `/dev/null`. Good luck. – shellter Feb 23 '21 at 00:45
  • After restart with >/dev/null, the terminal window does not update anymore – GVK AWESOME Feb 23 '21 at 18:17
  • Looks like I had to type pgrep -f >/dev/null That solved the problem, thanks guys – GVK AWESOME Feb 23 '21 at 21:48
  • `pgrep -f >/dev/nul` ?? It may be failing silently. Did you include a search target for `pgrep` that you didn't include in your example above? Good luck. – shellter Feb 26 '21 at 00:41

0 Answers0