I'm running a minecraft server on ubuntu 20.04. I have a script to execute it and works fine.
However i can't get it to work @reboot with cron, because it can't find the jar file. From what i researched, it seems cron doesn't run with my user (although i'm not using sudo). What are my options?
This is my crontab -e:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
00 01 * * * /home/eggzaile/minecraft/backup.sh 2>>&1
@reboot sleep 45 && /usr/bin/screen -dmS minecraft sh -c '/home/eggzaile/minecraft/start.sh; exec bash' 2>>&1
after the reboot and cron kicks in, when i attach to that window...all i see is the error about not finding the jar file.
this is the script itself:
#!/bin/sh
while true
do
java -Xms3G -Xmx3G -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 paper-1.16.5-778.jar nogui
sleep 5
done
I red somehere that using the full path on the script should work, but that breaks it, i tried. i used (java -jar /path/to/server.jar and all the arguments here), but apparently i should not change the order.
Any tips?