I have written a bash script to run a service in background and exit from the script to command line. But after running the eval command, control does not go the next statement.
COMMAND="nohup java -jar jenkins.war"
echo "starting service"
eval $COMMAND
echo "service running"
exit
echo “service running” and exit never happens. I want to run the process in the background, and return to the command prompt while the service is still running. How do I do this?
Please, don’t put a command with its arguments in a string. Put your command and its arguments in an array (and don’t use upper-case variable names, that’s a terribly bad practice), and do not use
eval.evalis evil!The
&is to have the command running in background.