I've seen many examples how to run bash script, I tried several and for some reason, my script fails in some functionality.
I have a script start_update_set_up that is runned by launcher:
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Script directory:"$DIR
nohup bash -c $DIR/start_update_set_up > $DIR/logs/start_update_set_up.log &
echo "Laucher finish execution"
If I run launcher directly from bash - if works perfectly. But if I try to run it from Java, sleep and curl function fails. Moreover, Java waiting for some reason while my main script finish execution, that I do not want and that's why I implement launcher and that's why do I want to detach it from Java by nohup
I tried: apache executor:
executor.execute(commandLine, new DefaultExecuteResultHandler());
Where commandline is my launcher.
and runtime.
Runtime runtime = Runtime.getRuntime();
try { Process process = runtime.exec("./launcher"); } catch (IOException e) {
logger.error("ExecuteException at running update script");
e.printStackTrace();
}
What am I missing? How to detach bash from Java?