How to automatically run Grails app after system reboot?

I am running a Grails 4.0.10 app using the following command:

nohup java -Dgrails.env=prod -Duser.timezone=US/Mountain -jar RCRoadRaceWeb4-0.1.jar &

The app connects to a MySQL 8 server.

When I reboot the system using the command

sudo reboot

after the system reboots.

When I check the running processes using ps -aux, I don't see the app running.

How can I make sure after the system completes rebooting the command:

nohup java -Dgrails.env=prod -Duser.timezone=US/Mountain -jar RCRoadRaceWeb4-0.1.jar &

gets executed automatically so that I don't have to manually run this command after system reboot to start the Grails app?


  • Documenting comments from above for anyone in the future, as they ended up providing a solution.

    nohup doesn't keep a process running through a reboot. To accomplish that, you'll need to either set up a service or use crontab. (There are probably other ways as well.)

    To configure a systemd service, there are many resources here and elsewhere; I will not repeat their contents here. OP found some useful links that are included in the comments above, for however long they stay available but in general searching for "how to create a systemd service" will lead to helpful results.

    As a simpler approach, you may add a line to crontab (crontab -e to edit) which will call a script on reboot: @reboot /path/to/script.sh This script can start whatever you need, such as both a database and application.

    Personally I would recommend the systemd approach as it is more robust, but crontab is perfectly sufficient for local development and testing, and probably simpler.