Forked from GuySawyer/gist:fae11b0efefd20927ef029c6b3c6fd4e
Created
May 7, 2024 02:53
-
-
Save linpan0/d1e4cc624e4e9d5ac3813a5c3cbc6378 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 - Starting a Java JAR on Boot using systemd
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
Jessie has moved away from sysvinit and onto systemd. Writing an init script to /etc/init.d/ is outdated, | |
and a bit tedious since you have to handle the start/stop/restart logic yourself (if you want those capabilities). | |
New Method: | |
1. Write a unit file for systemd. | |
$ sudo nano /etc/systemd/system/your_jar_software.service | |
[Unit] | |
Description=Example on starting a JAR with systemd | |
After=network.target | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/java -jar /home/pi/path/to/your/JAR.jar | |
[Install] | |
WantedBy=multi-user.target | |
2. Start it at boot | |
$ sudo systemctl enable your_jar_software | |
3. Manually control it | |
$ sudo systemctl start|stop|status|restart your_jar_software | |
4. Observe the output | |
$ sudo journalctl -u your_jar_software |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment