Skip to content

Instantly share code, notes, and snippets.

@rasmusmerzin
Last active September 18, 2020 11:36
Show Gist options
  • Save rasmusmerzin/6d21acb87632b9ee1110793e21046acb to your computer and use it in GitHub Desktop.
Save rasmusmerzin/6d21acb87632b9ee1110793e21046acb to your computer and use it in GitHub Desktop.
#!/bin/sh
mem_min=1
mem_max=$((($(free -m | awk '/^Mem:/{print $2}')-128)/1024))
mem=$(printf "%d" "$1")
if [ "$mem" -lt "$mem_min" ]
then mem=$mem_min
elif [ "$mem" -gt "$mem_max" ]
then mem=$mem_max
fi
cmd="java -Xmx${mem}G -Xms${mem}G -jar server.jar nogui"
echo "> $cmd"
eval "$cmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment