Last active
September 18, 2020 11:36
-
-
Save rasmusmerzin/6d21acb87632b9ee1110793e21046acb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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