sudo nano /etc/systemd/system/app.service
[Unit]
Description=APP name service
[Service]
WorkingDirectory=/home/ubuntu/appdir
ExecStart=/opt/jdk1.8.0_201/bin/java -jar /home/ubuntu/appdir/app.jar
User=ubuntu
Type=simple
Restart=on-failure
RestartSec=5
StandardOutput=null
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable app.service
sudo systemctl start app
sudo systemctl status app
-- list managed services
systemctl list-unit-files --type service
-- list services
systemctl list-units --type=service --state=running
-- show systemctl log
journalctl -f
-- edit service
systemctl edit app.service
systemctl daemon-reload
systemctl restart app.service
-- delete service
systemctl stop app
systemctl disable app
rm /etc/systemd/system/app
rm /etc/systemd/system/app
systemctl daemon-reload
systemctl reset-failed