When I execute below script from cli it is working and process in background also running. But when i try to execute the same wcript from ansible all the tasks are successfully executing but background process is not running. shell scipt

if [ -d "deploy" ];then
rm -rf deploy
echo "Removed Existing Pack"
echo "WorkSpace Cleared"
chmod -R 777 Installer-bin.zip
unzip Installer-bin.zip
chmod -R 777 /home/NK/SK_INSTALL/deploy
cp /home/NK/SK_INSTALL/Config/install.xml /home/NK/SK_INSTALL/deploy
cd /home/NK/SK_INSTALL/deploy
cp /home/NK/SK_INSTALL/Config/start-soft-autoinstall.sh 
cd $SK_DEPLOY_PATH/deploy
dos2unix start-soft-autoinstall.sh
echo $rc
echo $rc
echo $rc
echo $rc
echo $rc
if [ $rc == "0" ]; then
echo "Exiting 1st loop"
exit 0
currentBuild.result = 'SUCCESS'
if [ $rc != "0" ]; then
echo "Done"
echo "Exiting 2st loop"
exit 0

Here is the start-soft-autoinstall.sh script

export JAVA_HOME=/home/suntec/jdk1.8.0_51
export ORACLE_HOME=/home/oracle/orahome
java -cp log4j-1.2.12.jar:jsch-0.1.42.jar:tools-0.0.1.jar:jdom-1.0.jar:. -jar precheck-0.0.1.jar $1

let me know any solution for this issue.

  • Try with nohup ./start-soft-autoinstall.sh (Try with two shell to see that, run the script in one, close it, and check, your detached process will be ended with the end of your shell) – Tensibai Nov 21 '18 at 10:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.