https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_Minecraft_Forge_server
Neoforge works the exact same way
java -jar forge-x.xx.x-installer.jar --installServeruser_jvm_args.txt:user_jvm_args.txt
# Xmx and Xms set the maximum and minimum RAM usage, respectively.
# They can take any number, followed by an M or a G.
# M means Megabyte, G means Gigabyte.
# For example, to set the maximum to 3GB: -Xmx3G
# To set the minimum to 2.5GB: -Xms2500M
# A good default for a modded server is 4GB.
# Uncomment the next line to set it.
-Xmx6G
-Xms4G
run.sh as follows:#!/usr/bin/env sh
# Forge requires a configured set of both JVM and program arguments.
# Add custom JVM arguments to the user_jvm_args.txt
# Add custom program arguments {such as nogui} to this file in the next line before the "$@" or
# pass them to this script directly
java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.19.4-45.2.15/unix_args.txt nogui "$@"
run.sh. It will generate world and fail because eula needs to be acknowledged. Acknowledge the Eula and install mods in the mods folder at root directory (it was generated)screen utility with apt install screen. Then, from https://linuxize.com/post/how-to-use-linux-screen/ run screen -dmS [session_name] [command] (from screen --help) to open a new terminal named [session_name] and run [command], (which would be./run.sh). The server should now be in the backgroundscreen -r (also from https://linuxize.com/post/how-to-use-linux-screen/). Pressing Ctrl a and Ctrl d should detach you from the session.screen -ls to identify all screen sessionsscreen without the dmS option, but you'll have some user interaction. Pressing Ctrl a and Ctrl d should detach you from the session.@reboot cd /mnt/server && screen -dmS minecraft ./run.sh
Source : https://phoenixnap.com/kb/crontab-reboot