Please note: Although the two primary techs in this question are Spring Boot and Gradle, I really think this is a Linux/command-line question at heart, involving fore- and background processes!
./gradlew build --continuous
./gradlew build --continuous & ./gradlew bootRun && fg
The successful runs were run in separate terminals, so perhaps the unsuccessful runs were fighting over the same resources, (whatever those might be). Try using separate subshells:
# 1) launch 1st program in background subshell. # 2) sleep 30 seconds # 3) launch 2nd program in background subshell. # 4) foreground '3)'. (It didn't need to be in the background.) ( ./gradlew build --continuous & ) ; sleep 30s && ( ./gradlew bootRun & ) ; fg
Commands in parenthesis are launched in a subshell. In an open terminal, suppose we run
bash or another shell and then assign a variable, then type
exit, and try to use that variable:
$ PS1='~> ' dash # assign a temporary prompt, run subshell ~> foo=bar ~> echo :$foo: :bar: ~> exit $ echo :$foo: ::
Above '$' is the main shell prompt, (don't type that), and '-> ' is the subshell's prompt, (don't type that either). The colons ('::') aren't commands, they help show when $foo is unset or empty. Variable assignments cannot leave a subshell, (nor can they cross over to a concurrent subshell).
See also "Compound Commands" in