I’m new to Ubuntu, and I want to run a (java maven) command which starts a web server embedded with my web application, on a remote Ubuntu server.
I can run it with following bash command (typed directly to remote console):
#!/bin/bash cd /path/to/mywebapp-dir mvn exec:java >> /opt/mywebapp.log
My web application keeps alive UNTIL I enter some key OR log out from console.
I want to keep it alive after I log out,
so I made a following systemctl service:[Unit] Description = mywebapp daemon [Service] ExecStart = /opt/mywebapp.sh # bash from above Restart = no Type = simple # also tried "forking", but couldn't get rid of PID file error. [Install] WantedBy = multi-user.target
But when I start the service, it seems to be shutting down right after the maven command has been successfully completed, and won’t keep the web application (which I assume to be a child process) alive.
How can I make it happen?
Answer
Attribution
Source : Link , Question Author : Hirofumi Okino , Answer Author : Community