Create a daemon
Check if we have systemd or other othe software suites:
pidof systemd && echo "systemd" || echo "other"
If we have systemd, then we should create a .service file.
nano /etc/systemd/system/MyProjectName.service
Copy, paste and edit these rows.
[Unit] Description= MyProjectDescription User=root Group=root Type=simple ExecStart=/usr/bin/java -jar /home/ubuntu/myspringproject/latest/MyProjectName-1.0.0.RELEASE.jar SuccessExitStatus=143[Install] WantedBy=multi-user.target
Enable your new service.
systemctl enable MyProjectName
Start your service.
systemctl start MyProjectName
Check the status of your daemon.
sudo systemctl status MyProjectName
Check daemon’s log.
journalctl -u MyProjectName.service --no-pager
Reload all unit files, and recreate the entire dependency tree.
systemctl daemon-reload
Restart your service.
systemctl restart MyProjectName
Adjust daemon log size / permanence
journalctl --vacuum-size=500M # or journalctl --vacuum-time=2d
Remove daemon
systemctl stop [servicename] systemctl disable [servicename] rm /etc/systemd/system/[servicename] rm /etc/systemd/system/[servicename] # and symlinks
Remove also
rm /usr/lib/systemd/system/[servicename] rm /usr/lib/systemd/system/[servicename] # and symlinks
Reload
systemctl daemon-reload systemctl reset-failed