Since you mentioned Ubuntu, most newer versions now support systemd. To set something like this up using systemd you'd create a systemd unit file and then enable it.
1. Software
First decide where you want to locate your software. I'd recommend /opt/core-price-update
.
Something like this:
$ tree /opt/menu-core-prices-update/
/opt/menu-core-prices-update/
├── application.conf
└── menu-core-prices-update-0.0.1-SNAPSHOT.jar
0 directories, 2 files
2. systemd unit file
Next create a systemd unit file like this:
$ cat /etc/systemd/system/menu-core-prices-update.service
[Unit]
Description=Menu Core Prices Update Daemon
After=network.target
[Service]
Environment="APP_CP=/opt/menu-core-price-update"
Environment="JAVA_HOME=/usr/java/latest"
Environment="APP_NAME=com.myapps.MenuCorePriceUpdate"
Environment="APP_NAME_JPROP=appname=menu-core-price-update"
Environment="CONFIG_FILE=/opt/menu-core-price-update/application.conf"
Environment="LOGPATH=/var/log/menu-core-price-update"
ExecStartPre=/bin/mkdir -pm 0755 ${LOGPATH}
ExecStart=/bin/bash -c "$JAVA_HOME/bin/java -D${APP_NAME_JPROP} -cp ${APP_CP} ${APP_NAME}"
PIDFile=/run/core-price-update/menu-core-price-update%i.pid
Restart=on-abort
RuntimeDirectory=menu-core-price-update
RuntimeDirectoryMode=755
WorkingDirectory=/opt/menu-core-price-update
[Install]
WantedBy=multi-user.target
3. Enable service
To enable this service to run between reboots:
$ sudo systemctl enable --now menu-core-prices-update
References