Automated restart script for Java app on Linux Mint 20 using Bash
Automated restart script for Java app on Linux Mint 20 using Bash
Hi I'm running a minecraft server .jar on Linux mint 20. I need help making a bash script that will automatically restart the process if it is closed or crashes (there are somewhat frequent crashes.) I'm currently just using the java -jar command with a few arguments in my current bash script for running the server. It's very annoying to have to manually restart the server every time it crashes, especially if my friends are trying to play and I'm not available to re start the server. Thank you for reading!
Unable to configure it as a service through systemd. Verify the details if needed.
Creating a service doesn't guarantee automatic restarts when the Java program exits. You need to configure systemd or another service manager properly.
Review the template comment carefully. You have flexibility to adjust memory limits and JVM options. The command includes restart settings that mimic Windows services or task schedulers.
You're finding systemd's capabilities interesting. Before, copying service info was enough, but now you want to monitor the actual output. A while loop with a pause seems practical for controlling restarts without constant interruptions. Using an autorestart script after boot helps manage automatic restarts. Switching to SSH would make things smoother, allowing remote control and easier access to logs. Systemctl status won't display terminal output directly, but you can check service statuses and logs through the systemd interface. If you can SSH in, it would be much more convenient than VNC.
Journald is integrated into systemd to continuously record all events related to your services. For more information, search for journald on Google. Systemd was designed specifically to address the issues you mentioned, eliminating the need for temporary fixes like yours (though your approach is perfectly acceptable). Remember, you can easily redirect standard output and error streams from any command to a file using "your command > log.txt".