Jump to content

Execute a jar file at startup, and have a terminal open for it so it can log whatever is happening

So I have been searching for answers all over the place and found some answers, but not to the most important part.

Backstory: I want to make a Minecraft server through the Pi 4 B. I have no problem doing it on Windows but I have absolutely no experience with Raspbian. I'm running Raspbian with desktop.

 

To run the .jar file required to run the server at startup, I have done this:

 

sudo nano /etc/rc.local

java -Xms1024M -Xmx4096M -DIReallyKnowWhatIAmDoingThisUpdate=true -jar /home/pi/mc_server/spigot-1.14.4.jar -o true &

# I do not know whether this will open a terminal window which I absolutely need. This is the most important part.

For restarting the Pi at 4 AM:

sudo crontab -e

0 4 * * * /sbin/shutdown -r now

# Assuming the previous code works, this sould make it restart and afterwards execute the server, as I will turn on auto login.

 

For a .desktop executable (so I can double click and run if I need to manually close it):

 

cd /home/pi/Desktop/mc_server.desktop

nano /home/pi/Desktop/mc_server.desktop

 

# I do not know whether this will create the executable, but internet says yes.

 

[Desktop Entry]

Name=mc_server

# Not mandatory # Comment=Run the server

# Not mandatory # Icon=have a look in the /usr/share/pixmaps/

Exec=java -Xms1024M -Xmx4096M -DIReallyKnowWhatIAmDoingThisUpdate=true -jar /home/pi/mc_server/spigot-1.14.4.jar -o true &

Type=Application

Encoding=UTF-8

Terminal=true

Categories=None;

 

 

So I don't physically own the Pi 4 B, but it's shipping and it will arrive in about a week. I want to be fully prepared to waste as little time as possible setting it up and researching. I would really appreciate if you could comment on my code and tell me if and where I went wrong. Thank you in advance.

Link to comment
Share on other sites

Link to post
Share on other sites

Minecraft should log all console output itself. All you need to do is start it.

Specs: CPU - Intel i7 8700K @ 5GHz | GPU - Gigabyte GTX 970 G1 Gaming | Motherboard - ASUS Strix Z370-G WIFI AC | RAM - XPG Gammix DDR4-3000MHz 32GB (2x16GB) | Main Drive - Samsung 850 Evo 500GB M.2 | Other Drives - 7TB/3 Drives | CPU Cooler - Corsair H100i Pro | Case - Fractal Design Define C Mini TG | Power Supply - EVGA G3 850W

Link to comment
Share on other sites

Link to post
Share on other sites

Welcome to the forums!

 

I have merged your two threads. For clutter reasons, we discourage making multiple threads for the same issue. Just one is enough and with patience you will get the help you need :)


Cheers!

We have a NEW and GLORIOUSER-ER-ER PSU Tier List Now. (dammit @LukeSavenije stop coming up with new ones)

You can check out the old one that gave joy to so many across the land here

 

Computer having a hard time powering on? Troubleshoot it with this guide. (Currently looking for suggestions to update it into the context of <current year> and make it its own thread)

Computer Specs:

Spoiler

Mathresolvermajig: Intel Xeon E3 1240 (Sandy Bridge i7 equivalent)

Chillinmachine: Noctua NH-C14S
Framepainting-inator: EVGA GTX 1080 Ti SC2 Hybrid

Attachcorethingy: Gigabyte H61M-S2V-B3

Infoholdstick: Corsair 2x4GB DDR3 1333

Computerarmor: Silverstone RL06 "Lookalike"

Rememberdoogle: 1TB HDD + 120GB TR150 + 240 SSD Plus + 1TB MX500

AdditionalPylons: Phanteks AMP! 550W (based on Seasonic GX-550)

Letterpad: Rosewill Apollo 9100 (Cherry MX Red)

Buttonrodent: Razer Viper Mini + Huion H430P drawing Tablet

Auralnterface: Sennheiser HD 6xx

Liquidrectangles: LG 27UK850-W 4K HDR

 

Link to comment
Share on other sites

Link to post
Share on other sites

I keep forgetting that RPi's are quad cores now and can handle it. I still own the original one and think how the hell will it manage that lol.

 

In short, what you need to be looking at and reading about is systemd. This service is responsible for bootstrapping all the processes in the system, you can use it to set up a service out of what you just posted, and set it to start automatically on startup. Services are written in files similar to that desktop entry file. Read about it, learn about it, and you'll get there. Raspbian is just another Linux distribution (with some extra RPi specific tools), if you're familiar with Linux you'll be fine.

 

Another thing that I would do, is disable the GUI completely and run in terminal mode only. Should save some RAM, which Java really likes (ie your MC server).

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×